<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="chrome=1">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
	<meta name="description" content="Race as fast as you can to get away from the cops!">
	<meta name="keywords" content="">

	<meta name="oupengmobile" content="game,fullscreen,landscape">

	<title>Lose the Heat</title>
	<link rel="shortcut icon" href="media&#x2F;images&#x2F;icons&#x2F;favicon.ico">
	<link rel="apple-touch-icon-precomposed" href="media&#x2F;images&#x2F;icons&#x2F;114.png">
	<link rel="image_src" href="media&#x2F;images&#x2F;icons&#x2F;114.png">
	<style>
	#spilgames-splash-screen {
		width: 100%;
		height: 100%;
		background: url("http://www8.agame.com/mirror/img/Splash_Image_A10.png") top center no-repeat;/* Change "A10" to "GGG" or "Zibbo" based on the brand your game matches */
		position: absolute;
		z-index: 10000; /* Make sure its on top of the game */
		background-size: 90%;
		background-color:#3890ae; /* Change to #FFF for GGG or Zibbo branded games */
	}
	.spilgames-splash-screen-gone {
		display:none !important;
	}
</style>

	<style>
		html, body {
			overflow: hidden;
			background: #000;
			margin: 0;
		}
		canvas {
			background: #000;
		}
		#djinn-game-info {
			display: none;
		}
	</style>

</head>
<body>

	<div id="djinn-game-info">
		<h1>Lose the Heat</h1>
		<p>Race as fast as you can to get away from the cops!</p>
		<p></p>
	</div>



	<script src="./game.js"></script>

	<script>
/*
Copyright © 2012 Lost Decade Games, LLC

Visit us on the web: http://www.lostdecadegames.com
Email us: hello@lostdecadegames.com
Follow us on Twitter: @LostDecadeGames

*/

if (window.require) {
	window.gui = require("nw.gui");
	window.requireNode = window.require;
	window.require = undefined;
}

__manifest={"launch":"js/Heat","title":"Lose the Heat","description":"Race as fast as you can to get away from the cops!","shortName":"heat","sizes":[[852,480]],"favicon":"media/images/icons/favicon.ico","icons":{"16":"media/images/icons/16.png","19":"media/images/icons/19.png","29":"media/images/icons/29.png","42":"media/images/icons/42.png","48":"media/images/icons/48.png","114":"media/images/icons/114.png","128":"media/images/icons/128.png","256":"media/images/icons/256.png","favicon":"media/images/icons/favicon.ico"},"orientation":"landscape","version":"1.1.4","scripts":["./game.js"],"headEmbed":"includes/spil-splash-head.html","bodyEmbed":"includes/spil-splash-body.html","port":8821};
__intl={"BEST_N":"Best: %s","BOOST_CHARGES_N":"Boost Charges: %s","BUY_N":"Buy $%s","CASH_N":"Cash: $%s","CHOOSE_CONTROLS":"Choose Controls:","CHOOSE_ZONE":"Choose Location","CONTINUE":"Continue","DRIVE":"Drive","DURABILITY_N":"Durability: %s","ESCAPED":"Escaped!","MORE_GAMES":"More Games","PLAY":"Play","QUIT":"Quit","RANK_N":"Rank: %s","RATING_0":"Very Easy","RATING_1":"Easy","RATING_2":"Normal","RATING_3":"Hard","RATING_4":"Very Hard","RESUME":"Resume","RETRY":"Retry","SOUND_ON":"Sound is on","SOUND_OFF":"Sound is off","TAP":"Tap","TILT":"Tilt","TIME_N":"Time: %s","TOP_SPEED_N":"Top Speed: %s mph","WRECKED":"Wrecked!","YOUR_GARAGE":"Your Garage","ZONE_DESERT":"Shifting Sands","ZONE_FOREST":"Tangled Thicket","ZONE_BEACH":"Coconut Coast","ZONE_MOUNTAIN":"Razor Ridge","ZONE_SNOW":"Perilous Peak"};

/**
 * almond 0.1.1 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/jrburke/almond for details
 */

/*!
 *  howler.js v1.1.14
 *  howlerjs.com
 *
 *  (c) 2013, James Simpson of GoldFire Studios
 *  goldfirestudios.com
 *
 *  MIT License
 */

var requirejs,require,define;(function(e){function a(e,t){var n=t&&t.split("/"),i=r.map,s=i&&i["*"]||{},o,u,a,f,l,c,h;if(e&&e.charAt(0)==="."&&t){n=n.slice(0,n.length-1),e=n.concat(e.split("/"));for(l=0;h=e[l];l++)if(h===".")e.splice(l,1),l-=1;else if(h===".."){if(l===1&&(e[2]===".."||e[0]===".."))return!0;l>0&&(e.splice(l-1,2),l-=2)}e=e.join("/")}if((n||s)&&i){o=e.split("/");for(l=o.length;l>0;l-=1){u=o.slice(0,l).join("/");if(n)for(c=n.length;c>0;c-=1){a=i[n.slice(0,c).join("/")];if(a){a=a[u];if(a){f=a;break}}}f=f||s[u];if(f){o.splice(0,l,f),e=o.join("/");break}}}return e}function f(t,n){return function(){return u.apply(e,s.call(arguments,0).concat([t,n]))}}function l(e){return function(t){return a(t,e)}}function c(e){return function(n){t[e]=n}}function h(r){if(n.hasOwnProperty(r)){var s=n[r];delete n[r],i[r]=!0,o.apply(e,s)}if(!t.hasOwnProperty(r))throw new Error("No "+r);return t[r]}function p(e,t){var n,r,i=e.indexOf("!");return i!==-1?(n=a(e.slice(0,i),t),e=e.slice(i+1),r=h(n),r&&r.normalize?e=r.normalize(e,l(t)):e=a(e,t)):e=a(e,t),{f:n?n+"!"+e:e,n:e,p:r}}function d(e){return function(){return r&&r.config&&r.config[e]||{}}}var t={},n={},r={},i={},s=[].slice,o,u;o=function(r,s,o,u){var a=[],l,v,m,g,y,b;u=u||r;if(typeof o=="function"){s=!s.length&&o.length?["require","exports","module"]:s;for(b=0;b<s.length;b++){y=p(s[b],u),m=y.f;if(m==="require")a[b]=f(r);else if(m==="exports")a[b]=t[r]={},l=!0;else if(m==="module")v=a[b]={id:r,uri:"",exports:t[r],config:d(r)};else if(t.hasOwnProperty(m)||n.hasOwnProperty(m))a[b]=h(m);else if(y.p)y.p.load(y.n,f(u,!0),c(m),{}),a[b]=t[m];else if(!i[m])throw new Error(r+" missing "+m)}g=o.apply(t[r],a);if(r)if(v&&v.exports!==e&&v.exports!==t[r])t[r]=v.exports;else if(g!==e||!l)t[r]=g}else r&&(t[r]=o)},requirejs=require=u=function(t,n,i,s){return typeof t=="string"?h(p(t,n).f):(t.splice||(r=t,n.splice?(t=n,n=i,i=null):t=e),n=n||function(){},s?o(e,t,n,i):setTimeout(function(){o(e,t,n,i)},15),u)},u.config=function(e){return r=e,u},define=function(e,t,r){t.splice||(r=t,t=[]),n[e]=[e,t,r]},define.amd={jQuery:!0}})(),define("../djinn/lib/almond",function(){});var djinn={version:"2.70.8"},bind=function(t,n){return typeof n=="string"&&(n=t[n]),function(){n.apply(t,arguments)}},clone=function(t){return JSON.parse(JSON.stringify(t))},merge=function(){var t={};for(var n=arguments.length-1;n>=0;--n){var r=arguments[n];if(typeof r!="object")continue;for(var i in r){var s=r[i];if(s===undefined)continue;s&&typeof s.concat=="function"?t[i]=s.concat([]):s&&s.constructor===Object?t[i]=arguments.callee(s,t[i]):t[i]=s}}return t},sprintf=function(t){for(var n=1,r=arguments.length;n<r;++n)t=t.replace(/%s/,arguments[n]);return t};if(typeof requestAnimationFrame=="undefined")var requestAnimationFrame=window.mozRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){setTimeout(function(){e(Date.now())},17)};var logger=typeof console!="undefined"?console:{error:function(){},info:function(){},log:function(){},table:function(){},warn:function(){}};typeof logger.info!="function"&&(logger.info=logger.log),define("djinn/global",function(){}),define("djinn/Class",[],function(){uidSeed=0;var e=!1,t=/\b_super\b/,n=function(){};return n.uid=0,n.extend=function(n){var r=this.prototype;e=!0;var i=new this;e=!1;for(var s in n)i[s]=typeof n[s]=="function"&&typeof r[s]=="function"&&t.test(n[s])?function(e,t){return function(){var n=this._super;this._super=r[e];var i=t.apply(this,arguments);return this._super=n,i}}(s,n[s]):n[s];var o=function(){!e&&this.init&&this.init.apply(this,arguments)};return o.prototype=i,o.prototype.constructor=o,o.extend=arguments.callee,o.uid=String(++uidSeed),o},n}),define("djinn/Emitter",["djinn/Class"],function(e){return e.extend({init:function(e){var e=e||{};this._listenerKey=0,this._listeners={}},fire:function(e,t){for(var n in this._listeners){var r=this._listeners[n];if(r.eventName==e)if(r.method)r.method.apply(r.context,t);else if(r.methodName){var i=r.context[r.methodName];if(typeof i!="function")throw"Could not find method: "+r.methodName;i.apply(r.context,t)}}},on:function(e){var t={eventName:e};if(arguments.length==2)t.method=arguments[1];else{t.context=arguments[1];var n=arguments[2];typeof n=="string"?t.methodName=n:t.method=n}return this._listeners[++this._listenerKey]=t,this},removeListeners:function(){for(var e in this._listeners)delete this._listeners[e];this._listeners={}},removeListenersByContext:function(e){for(var t in this._listeners){var n=this._listeners[t];n.context===e&&delete this._listeners[t]}},off:function(e){var t=null;for(var n in this._listeners){var r=this._listeners[n];if(r.eventName==e)if(arguments.length==2){if(r.method==arguments[1]){t=n;break}}else{var i=arguments[1];if(i==r.context){var s=arguments[2];if(typeof s=="string"){if(s==r.methodName){t=n;break}}else{r.method=s;if(s==r.method){t=n;break}}}}}return t!==null&&delete this._listeners[t],this},remove:function(){this._listeners=null}})}),define("djinn/utils/keys",{tab:9,space:32,escape:27,backspace:8,enter:13,shift:16,up:38,down:40,left:37,right:39,n0:48,n1:49,n2:50,n3:51,n4:52,n5:53,n6:54,n7:55,n8:56,n9:59,w:87,a:65,s:83,d:68,c:67,x:88,e:69,m:77,q:81,z:90}),define("djinn/math/core",[],function(){var e={twoPi:Math.PI*2,sign:function(e){return e>0?1:e==0?0:-1},chance:function(t){var n=e.random(0,100)/100;return n<=t},random:function(e,t){return e instanceof Array?arguments.callee(0,e.length-1):Math.round(Math.random()*(t-e))+e},clamp:function(e,t,n){return Math.min(Math.max(e,t),n)},vary:function(t,n){return t+=e.random(-n,n)},interpolate:function(e,t,n){return e+(t-e)*n},scaleRange:function(e,t,n){return e+~~((t-e)*n)},combineRects:function(e,t){var n=e.x<t.x?e.x:t.x,r=e.y<t.y?e.y:t.y,i=e.x+e.width,s=e.y+e.height,o=t.x+t.width,u=t.y+t.height;return{x:n,y:r,width:(e.x+e.width>t.x+t.width?e.x+e.width:t.x+t.width)-n,height:(e.y+e.height>t.y+t.height?e.y+e.height:t.y+t.height)-r}},intersects:function(e,t){return e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height},pointInRect:function(e,t){return e.x>t.x&&e.y>t.y&&e.x<t.x+t.width&&e.y<t.y+t.height},pointInCircle:function(e,t,n,r,i){var s=Math.pow(e-n,2)+Math.pow(t-r,2);return s<Math.pow(i,2)},pointDistance:function(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},round:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}};return e}),define("djinn/utils/array",["djinn/math/core"],function(e){var t={isArray:function(e){return e?typeof e.unshift=="function":!1},force:function(e){return t.isArray(e)?e:[e]},contains:function(e,t){return e.indexOf(t)!==-1},containsAny:function(e,n){for(var r=0,i=n.length;r<i;++r)if(t.contains(e,n[r]))return!0;return!1},removeValue:function(e,t){var n=e.indexOf(t);if(n===-1)return;e.splice(n,1)},removeIndices:function(e,t){t.length>1&&t.sort(function(e,t){return t-e});for(var n=0,r=t.length;n<r;++n)e.splice(t[n],1)},addItems:function(e,t,n){for(var r=0,i=t.length;r<i;++r){var s=t[r];if(n&&e.indexOf(s)!==-1)continue;e.push(s)}},pushOnce:function(e,t){if(e.indexOf(t)!==-1)return;e.push(t)},pickRandom:function(t){var n=e.random(0,t.length-1);return t[n]},popRandom:function(t){var n=e.random(0,t.length-1),r=t[n];return t.splice(n,1),r},merge:function(e,t,n){var r=[];while(e.length>0&&t.length>0)n(e[0],t[0])<=0?r.push(e.shift()):r.push(t.shift());return r.concat(e,t)},sort:function(e,n){var r=e.length;if(r<2)return e;var i=Math.ceil(r/2);return t.merge(t.sort(e.slice(0,i),n),t.sort(e.slice(i),n),n)},shuffle:function(e){var t=e.length;if(t<1)return;while(--t){var n=Math.floor(Math.random()*(t+1)),r=e[n];e[n]=e[t],e[t]=r}return e},max:function(e){var t=e[0]||0;for(var n=0,r=e.length;n<r;++n)t=Math.max(e[n],t);return t},sum:function(e){var t=0;for(var n=0,r=e.length;n<r;++n){if(isNaN(e[n]))continue;t+=e[n]}return t}};return t}),define("djinn/keyboard",["djinn/Emitter","djinn/utils/keys","djinn/utils/array"],function(e,t,n){var r=e.extend({init:function(e){this._super(e),this._capture=[],this.keys=t,this._keysDown={},this._keyHistory=[],this._lastKeysDown={},this._shiftDown=!1,window.addEventListener("keydown",bind(this,"_handleKeyEvent"),!1),window.addEventListener("keyup",bind(this,"_handleKeyEvent"),!1)},capture:function(e){var t=this._capture;e.forEach(function(e){if(t.indexOf(e)!==-1)return;t.push(e)})},endFrame:function(){this._lastKeysDown={};for(var e in this._keysDown)this._lastKeysDown[e]=this._keysDown[e]},checkHistory:function(e){var t=e.length,n=this._keyHistory.slice(-t);if(n.length!=t)return!1;for(var r=0;r<t;r++)if(e[r]!==n[r])return!1;return!0},clearHistory:function(){this._keyHistory=[]},isDown:function(e,t){n.isArray(e)||(e=[e]);for(var r=0,i=e.length;r<i;++r)if(this._keysDown[e[r]])if(t!==!0||this._lastKeysDown[e[r]]!==!0)return!0;return!1},isShiftDown:function(){return this._shiftDown},isAnyDown:function(){for(var e in this._keysDown)return!0;return!1},clearKeys:function(e){var e=n.force(e);for(var t=0,r=e.length;t<r;++t)delete this._keysDown[e[t]]},_handleKeyEvent:function(e){this._capture.indexOf(e.keyCode)!==-1&&e.preventDefault(),e.type==="keydown"?(this._keysDown[e.keyCode]=!0,this._keyHistory.push(e.keyCode),this._keyHistory.length>50&&this._keyHistory.shift()):e.type==="keyup"&&delete this._keysDown[e.keyCode],this._shiftDown=e.shiftKey}});return new r}),define("djinn/utils/buttons",{dPadUp:12,dPadDown:13,dPadLeft:14,dPadRight:15,face1:0,face2:1,face3:2,face4:3,shoulderTopLeft:4,shoulderTopRight:5,shoulderBottomLeft:6,shoulderBottomRight:7,select:8,start:9,analogLeft:10,analogRight:11}),define("djinn/gamepad",["djinn/Emitter","djinn/utils/buttons","djinn/utils/array"],function(e,t,n){var r=.75,i=.25,s=.3,o=.3,u={up:function(e,t){return e.axes[1]<-t},down:function(e,t){return e.axes[1]>t},left:function(e,t){return e.axes[0]<-t},right:function(e,t){return e.axes[0]>t}},a=function(e){var t=navigator.getGamepads||navigator.webkitGetGamepads;if(!t)return null;var n=t.call(navigator),r=n[e||0];return r},f=e.extend({init:function(e){this._super(e),this.buttons=t,this.threshold=r,this._buttonsDown={},this._lastButtonsDown={}},exists:function(){return!!a()},endFrame:function(){this._lastButtonsDown={};for(var e in this._buttonsDown)this._lastButtonsDown[e]=this._buttonsDown[e]},getAnalogData:function(e){var t={x:0,y:0,magnitude:0,magnitudeNormal:0},n=a();if(!n)return t;var r=n.axes,u=e==="left",f=u?s:o,l=u?r[0]:r[2],c=u?r[1]:r[3];Math.abs(l)<i&&(l=0),Math.abs(c)<i&&(c=0);var h=Math.sqrt(l*l+c*c),p=l/h,d=c/h;if(h>f){h=Math.min(h,1),h-=f;var v=h/(1-f);t.x=l,t.y=c,t.xNormal=p,t.yNormal=d,t.magnitude=h,t.magnitudeNormal=v}return t},isButtonDown:function(e,t){var n=a();if(!n)return!1;var r=n.buttons[e]>this.threshold,i=r;return t&&(i=r&&!this._buttonsDown[e]),this._buttonsDown[e]=r,i},clearButtons:function(e){var t=a();if(!t)return!1;var e=n.force(e);e.forEach(function(e){t.buttons[e]=!1},this)},isDirectionDown:function(e,t){var n=a();return n?u[e](n,this.threshold):!1}});return new f}),define("djinn/globalTimer",["djinn/Emitter"],function(e){var t=1e3,n=120,r=e.extend({init:function(e){this._super(e),this.running=!1,this.fps=0,this.deltaTime=0,this.deltaTimeAverage=0,this.tickCount=0,this._lastUpdate=0,this._tickHistory=[]},start:function(){this.running=!0,this._lastUpdate=Date.now(),this._requestFrame()},stop:function(){this.running=!1},_requestFrame:function(){this.running&&requestAnimationFrame(bind(this,"_update"))},_update:function(e){++this.tickCount;var n=e-this._lastUpdate;n>t?(logger.warn("[globalTimer] dropping large tick: ",n),n=1):n<0&&(logger.warn("[globalTimer] negative delta: ",n),n=1),this._recordTick(n),this.deltaTime=n,this.fire("tick",[n]),this._lastUpdate=e,this._requestFrame()},_recordTick:function(e){var t=this._tickHistory.push(e);if(t>n){var r=0;for(var i=0;i<t;++i)r+=this._tickHistory[i];this.deltaTimeAverage=r/t,this.fps=~~(1e3/this.deltaTimeAverage),this._tickHistory=[]}}});return new r}),define("djinn/manifest",[],function(){return __manifest}),define("djinn/client",["djinn/Emitter","djinn/manifest"],function(e,t){var n=e.extend({init:function(e){this._super(e),this.debug=!1,this._detectEnvironment(),this._updateSize();if(this.isTouch){var t=bind(this,function(e){e.preventDefault()}),n=["touchstart","touchmove","touchend"];for(var r=0,i=n.length;r<i;++r)addEventListener(n[r],t,!1)}var s=bind(this,"_updateSize");window.addEventListener("resize",s,!1),window.addEventListener("orientationchange",s,!1),window.addEventListener("DOMContentLoaded",s,!1),window.addEventListener("load",bind(this,"_onLoad"),!1),this._initVisibilityChange(),window.addEventListener("tizenhwkey",bind(this,"_onTizenHardwareKey"),!1)},toggleFullScreen:function(){var e=window.gui;if(e){var t=e.Window.get();t.toggleFullscreen()}},open:function(e){var t=window.gui;t?t.Shell.openExternal(e):location.href=e},quit:function(){var e=window.gui;if(!e)return;e.App.quit()},vibrate:function(e){if(!navigator.vibrate)return;navigator.vibrate(e)},log:function(){if(arguments.length>1)var e=sprintf.apply(null,arguments);else var e=arguments[0];this.isXDK?AppMobi.webview.execute('console.log("'+e+'");'):console&&console.log&&console.log(e)},_detectEnvironment:function(){var e=this.userAgent=navigator.userAgent;this.pixelRatio=window.devicePixelRatio||1,this.isTouch=typeof window.ontouchstart!="undefined"||!this.isBrowser,this.isFullScreen=window.navigator.standalone===!0,this.isIPhone=/iPhone OS/.test(e),this.isIPad=/iPad/.test(e),this.isIOS=this.isIPhone||this.isIPad,this.isAndroid=/Android/.test(e),this.debug&&(this.log("[client._detectEnvironment] Debugging info:"),this.log("User Agent: %s",this.userAgent),this.log("Device: %s",this.deviceType),this.log("Pixel Ratio: %s",this.pixelRatio))},_queryWindowSize:function(){if(this.isXDK)return{width:AppMobi.canvas.width,height:AppMobi.canvas.height};var e={width:~~window.innerWidth,height:~~window.innerHeight};return e},_updateSize:function(){var e=this._queryWindowSize();if(e.width!==this.width||e.height!==this.height)this.width=e.width,this.height=e.height,this.debug&&this.log("[client._updateSize] %sx%s",this.width,this.height),window.scrollTo(0,0),this.fire("resize",[this.width,this.height,this.orientation])},_onLoad:function(){this._updateSize(),this.isAndroid&&setInterval(bind(this,"_updateSize"),500)},_initVisibilityChange:function(){var e=null;this._hiddenPropertyName=null,typeof document.hidden!="undefined"?(e="visibilitychange",this._hiddenPropertyName="hidden"):typeof document.webkitHidden!="undefined"?(e="webkitvisibilitychange",this._hiddenPropertyName="webkitHidden"):typeof document.mozHidden!="undefined"?(e="mozvisibilitychange",this._hiddenPropertyName="mozHidden"):typeof document.msHidden!="undefined"&&(e="msvisibilitychange",this._hiddenPropertyName="msHidden");if(!e)return;document.addEventListener(e,bind(this,"_onVisibilityChange"),!1)},_onVisibilityChange:function(){this.fire("visibilityChange",[this.hidden])},_onTizenHardwareKey:function(e){if(e.keyName)var t=e.keyName;else if(e.originalEvent&&e.originalEvent.keyName)var t=e.originalEvent.keyName;else var t=null;switch(t){case"back":tizen.application.getCurrentApplication().exit()}}});return Object.defineProperty(n.prototype,"orientation",{get:function(){var e=this.width>=this.height?"landscape":"portrait";return isNaN(window.orientation)&&t.orientation!=="both"?t.orientation:e}}),Object.defineProperty(n.prototype,"hidden",{get:function(){return this._hiddenPropertyName?document[this._hiddenPropertyName]:!1}}),Object.defineProperty(n.prototype,"deviceType",{get:function(){return this.isAndroid?"Android":this.isIPhone?"iPhone":this.isIPad?"iPad":"Unknown"}}),Object.defineProperty(n.prototype,"isBrowser",{get:function(){return document&&typeof document.querySelectorAll=="function"&&!this.isCocoonJS&&!this.isXDK}}),Object.defineProperty(n.prototype,"isCocoonJS",{get:function(){return navigator.isCocoonJS}}),Object.defineProperty(n.prototype,"isXDK",{get:function(){return typeof AppMobi!="undefined"}}),Object.defineProperty(n.prototype,"isTizen",{get:function(){return typeof tizen!="undefined"}}),new n}),define("djinn/utils/request",["require","exports","module","../client"],function(e,t,n){var r=e("../client");t.params={},r.isBrowser&&location.href.replace(/[?&]+([^=&]+)=([^&#]*)/gi,function(e,n,r){t.params[n]=r})}),define("djinn/stage",["require","exports","module","./Emitter","./client","./math/core","./manifest","./utils/request"],function(e,t,n){var r=e("./Emitter"),i=e("./client"),s=e("./math/core"),o=e("./manifest"),u=e("./utils/request"),a=[],f=!1,l=["touchstart","touchmove","touchend"],c=["mousedown","mousemove","mouseup"],h=r.extend({init:function(e){this._super(e),this.eraseBeforeRender=!1,this._maxScale=Infinity,this.maintainAspectRatio=o.scaleMode!=="stretch",this.doubleBuffer=!1,this._buffer=null,this._bufferCtx=null,this.acceptInput=!1,this.xInput=0,this.yInput=0,this.inputDown=!1,this.viewportWidth=0,this.viewportHeight=0,this.canvas=null,this.ctx=null,this.xScale=1,this.yScale=1,i.isTizen&&(this.doubleBuffer=!0,this.eraseBeforeRender=!0);if(i.isXDK)var t=this.canvas=AppMobi.canvas;else{var n=this.isCocoonJS?"screencanvas":"canvas",t=this.canvas=document.createElement(n);t.width=i.width,t.height=i.height,i.isBrowser&&(t.style.position="absolute",t.style.left=0,t.style.top=0),document.body.appendChild(t)}this._initInput(),this.ctx=t.getContext("2d"),i.on("resize",this,"_autoSize")},matchSize:function(e){if(!e||e.length===0){logger.warn("[stage] sizes needs to be set in manifest",e);return}var t=null,n=Infinity,r=0,s=u.params.hd==="1",o=Math.min(i.width,i.height),a=Math.max(i.width,i.height);for(var f=0,l=e.length;f<l;++f){var c=e[f],h=Math.min(c[0],c[1]),p=Math.max(c[0],c[1]);if(s)p>r&&(t=[h,p],r=p,this.sizeIndex=f);else{var d=Math.abs(h*p-o*a);d<n&&(t=[h,p],n=d,this.sizeIndex=f)}}this.canvas.width=t[0],this.canvas.height=t[1],this._autoSize()},localizePoint:function(e,t){return i.isXDK?{x:e,y:t}:{x:Math.round((e-this.canvas.offsetLeft)*(1/this.xScale)),y:Math.round((t-this.canvas.offsetTop)*(1/this.yScale))}},renderView:function(e){var t=this.canvas,n=this.ctx;i.isXDK?n.clear():this.eraseBeforeRender&&n.clearRect(0,0,t.width,t.height);if(this.doubleBuffer){this._buffer||(this._buffer=this.createBuffer(t.width,t.height),this._bufferCtx=this._buffer.getContext("2d"));var r=this._buffer;this.eraseBeforeRender&&this._bufferCtx.clearRect(0,0,r.width,r.height),e.preRender(this._bufferCtx),n.drawImage(r,0,0,r.width,r.height,0,0,t.width,t.height)}else e.preRender(n);i.isXDK&&n.present()},createBuffer:function(e,t){var n=document.createElement("canvas");return n.width=Number(e),n.height=Number(t),n},getInputEvents:function(){var e=a;return a=[],e},requestFullScreen:function(){document.body.webkitRequestFullScreen()},cancelFullScreen:function(){document.webkitCancelFullScreen()},toggleFullScreen:function(){if(!this.canFullScreen)return;this.isFullScreen?this.cancelFullScreen():this.requestFullScreen()},setViewport:function(e,t){this.viewportWidth=e,this.viewportHeight=t,this._autoSize()},_getEventType:function(e){switch(e.type){case"touchstart":case"mousedown":return"inputStart";case"touchmove":case"mousemove":return"inputMove";case"touchend":case"mouseup":return"inputEnd"}},_handleInputEvent:function(e){if(!this.acceptInput)return;var t=-1,n=0,r=0;if(i.isTouch){var s=e.type==="touchend"?e.changedTouches[0]:e.touches[0];t=s.identifier,n=s.pageX,r=s.pageY}else n=e.pageX,r=e.pageY;var o={id:t,type:this._getEventType(e),point:this.localizePoint(n,r)};this.xInput=o.point.x,this.yInput=o.point.y,this.inputDown=o.type!=="inputEnd",a.push(o),this.fire(o.type,[o]),this.fire("input",[o]),f||(f=!0,this.fire("initialInput"))},_initInput:function(){var e=this.canvas,t=i.isTouch?l:c;for(var n=0,r=t.length;n<r;++n)e.addEventListener(t[n],bind(this,"_handleInputEvent"),!1)},_autoSize:function(){var e=this.canvas,t=Math.min(e.width,e.height),n=Math.max(e.width,e.height),r=o.orientation!=="both"&&o.forceOrientation,a=r?o.orientation:i.orientation;e.width=a=="portrait"?t:n,e.height=a=="portrait"?n:t;var f=this.viewportWidth||i.width,l=this.viewportHeight||i.height,c=f/e.width,h=l/e.height;i.isCocoonJS?(this.xScale=this.yScale=1,e.style.cssText="idtkscale:ScaleAspectFit;"):u.params.scale?this.xScale=this.yScale=Number(u.params.scale):this.maintainAspectRatio?this.xScale=this.yScale=Math.min(c,h):(this.xScale=c,this.yScale=h),i.log("[stage._autoSize] view: %sx%s, canvas: %sx%s, scale: %s, %s",f,l,e.width,e.height,s.round(this.xScale,3),s.round(this.yScale,3));var p="0 0";if(i.isIOS)var d=sprintf("scale3d(%s, %s, 1)",this.xScale,this.yScale);else var d=sprintf("scale(%s, %s)",this.xScale,this.yScale);if(i.isBrowser){var v=e.style;v.transformOrigin=p,v.transform=d;var m=["webkit","Moz","ms"];for(var g=0,y=m.length;g<y;++g){var b=m[g];v[b+"TransformOrigin"]=p,v[b+"Transform"]=d}v.left=i.width/2-e.width*this.xScale/2+"px",o.yStageAlign==="top"?v.top=0:v.top=i.height/2-e.height*this.yScale/2+"px"}this.fire("resize")}}),p=h.prototype;Object.defineProperty(p,"canFullScreen",{get:function(){return typeof document.webkitCancelFullScreen=="function"}}),Object.defineProperty(p,"isFullScreen",{get:function(){return document.webkitIsFullScreen}}),Object.defineProperty(p,"maxScale",{get:function(){return this._maxScale},set:function(e){this._maxScale=e,this._autoSize()}}),Object.defineProperty(p,"width",{get:function(){return this.canvas.width}}),Object.defineProperty(p,"height",{get:function(){return this.canvas.height}}),Object.defineProperty(p,"scaleWidth",{get:function(){return this.width*this.xScale}}),Object.defineProperty(p,"scaleHeight",{get:function(){return this.height*this.yScale}}),n.exports=new h}),define("djinn/assets",["djinn/client","djinn/manifest"],function(e,t){var n={},r={image:["png","jpg","jpeg","gif"],audio:["mp3"],font:["ttf"]},i={image:function(n,r,i){var s=new Image;s.onload=function(){s.ready=!0,r&&r(n,s)},s.onerror=function(){i&&i(n,s)};if(e.isBrowser&&n.substring(0,5)!="data:")var n=n+"?v="+t.version;return s.src=n,s},audio:function(t,n){if(typeof Audio=="undefined")return logger.warn("[assets] No Audio object: "+t),n&&n(t,null),null;var r=new Audio;if(r.canPlayType("audio/ogg")!=="")t=t.replace(/\.mp3/,".ogg");else if(r.canPlayType("audio/mpeg")==="")return logger.warn("[assets] No audio support: "+t),n&&n(t,null),null;return e.isBrowser?(r.addEventListener("canplay",function(){if(r.ready)return;r.ready=!0,n&&n(t,r)},!1),r.src=t):(r.addEventListener("canplaythrough",function(){r.ready=!0,n&&n(t,r)}),r.src=t,r.load()),r},font:function(t,n){if(e.isBrowser){var r=/^.*\/([^\.]+)\.ttf$/.exec(t),i=r[1],s=sprintf("@font-face { font-family: '%s'; src: url('%s'); }",i,t),o=document.createElement("style");o&&(o.innerHTML=s,document.body.appendChild(o))}return n&&n(t,null),null}},s={};return s.cacheImage=function(e,t){n[e]=i.image(t)},s.load=function(e,t,r){if(!e||e.length<1){r&&r(null,null,0,0,1),t&&t();return}typeof e=="string"&&(e=[e]);var o=e.length,u=0,a=function(e,i){n[e]=i,++u;var s=u/o;r&&r(e,i,u,o,s),u>=o&&t&&t()},f=function(e,t){logger.error("[assets.load] Failed to load asset: "+e),a(e,t)};for(var l=0,c=e.length;l<c;++l){var h=e[l];if(typeof h!="string"||h.length<=0)--o,logger.info("[assets.load] Skipping empty asset path");if(n[h])a(h,n[h]);else{var p=s.inferAssetType(h);if(p&&i[p]){var d=i[p];n[h]=d(h,a,f)}else--o,logger.info("[assets.load] Skipping unknown asset type: "+h)}}},s.unload=function(e){typeof e=="string"&&(e=[e]);for(var t=0,r=e.length;t<r;++t)delete n[e[t]]},s.queryCache=function(e){return n[e]!==undefined},s.get=function(e){return s.queryCache(e)||(logger.warn("[assets.get] On-the-fly asset load: "+e),s.load(e)),n[e]},s.inferAssetType=function(e){var t=e.split("."),n=t.length>0?t.pop():"";for(var i in r)if(r[i].indexOf(n)!=-1)return i;return null},s}),define("djinn/Timer",["djinn/Emitter","djinn/globalTimer"],function(e,t){var n=e.extend({init:function(e){this._super(),this._elapsed=0,this._loops=0,this._running=!1,this._tickHost=t,typeof e=="number"?this.interval=e:typeof e=="object"?(this.interval=Number(e.interval||1e3),this._tickHost=e.tickHost||this._tickHost):this.interval=1e3},reset:function(){return this.start()},start:function(e){return e!==undefined&&(this.interval=e),this._elapsed=0,this.resume()},resume:function(){return this._running||(this._tickHost.on("tick",this,"_update"),this._running=!0),this},stop:function(){return this._running&&(this._tickHost.off("tick",this,"_update"),this._running=!1),this},_update:function(e){this._elapsed+=e,this._elapsed>=this.interval&&(this._elapsed=0,++this._loops,this.fire("elapsed",[this._loops]))}});return Object.defineProperty(n.prototype,"elapsed",{get:function(){return this._elapsed}}),Object.defineProperty(n.prototype,"percentComplete",{get:function(){return this._elapsed/this.interval*100}}),Object.defineProperty(n.prototype,"running",{get:function(){return this._running},set:function(e){e?this.start():this.stop()}}),n}),define("djinn/utils/transitions",[],function(){var e={linear:function(e,t,n,r){return n*e/r+t},easeIn:function(e,t,n,r){return n*(e/=r)*e+t},easeOut:function(e,t,n,r){return-n*(e/=r)*(e-2)+t},easeBoth:function(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},inStrong:function(e,t,n,r){return n*(e/=r)*e*e*e+t},outStrong:function(e,t,n,r){return-n*((e=e/r-1)*e*e*e-1)+t},bothStrong:function(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e+t:-n/2*((e-=2)*e*e*e-2)+t},elasticIn:function(e,t,n,r,i,s){if(e==0)return t;if((e/=r)==1)return t+n;s||(s=r*.3);if(!i||i<Math.abs(n)){i=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/i);return-(i*Math.pow(2,10*(e-=1))*Math.sin((e*r-o)*2*Math.PI/s))+t},elasticOut:function(e,t,n,r,i,s){if(e==0)return t;if((e/=r)==1)return t+n;s||(s=r*.3);if(!i||i<Math.abs(n)){i=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/i);return i*Math.pow(2,-10*e)*Math.sin((e*r-o)*2*Math.PI/s)+n+t},elasticBoth:function(e,t,n,r,i,s){if(e==0)return t;if((e/=r/2)==2)return t+n;s||(s=r*.3*1.5);if(!i||i<Math.abs(n)){i=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/i);return e<1?-0.5*i*Math.pow(2,10*(e-=1))*Math.sin((e*r-o)*2*Math.PI/s)+t:i*Math.pow(2,-10*(e-=1))*Math.sin((e*r-o)*2*Math.PI/s)*.5+n+t},backIn:function(e,t,n,r,i){return i===undefined&&(i=1.70158),n*(e/=r)*e*((i+1)*e-i)+t},backOut:function(e,t,n,r,i){return i===undefined&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t},backBoth:function(e,t,n,r,i){return i===undefined&&(i=1.70158),(e/=r/2)<1?n/2*e*e*(((i*=1.525)+1)*e-i)+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},bounceIn:function(t,n,r,i){return r-e.bounceOut(i-t,0,r,i)+n},bounceOut:function(e,t,n,r){return(e/=r)<1/2.75?n*7.5625*e*e+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},bounceBoth:function(t,n,r,i){return t<i/2?e.bounceIn(t*2,0,r,i)*.5+n:e.bounceOut(t*2-i,0,r,i)*.5+r*.5+n}};return e}),define("djinn/View",["require","exports","module","./client","./Emitter","./assets","./globalTimer","./Timer","./stage","./math/core","./utils/array","./utils/transitions"],function(e,t,n){var r=e("./client"),i=e("./Emitter"),s=e("./assets"),o=e("./globalTimer"),u=e("./Timer"),a=e("./stage"),f=e("./math/core"),l=e("./utils/array"),c=e("./utils/transitions"),h=0,p=function(e,t){return e.z===t.z?e.id-t.id:e.z-t.z},t=n.exports=i.extend({init:function(e){var n=++h;e=merge(e,{id:n,tag:"View_"+n},t.defaults),e.parent&&(e.width=e.width||e.parent.width,e.height=e.height||e.parent.height),this._super(e),this.id=e.id,this.tag=e.tag,this.x=e.x,this.y=e.y,this._z=e.z,this.anchorX=e.anchorX||e.width/2,this.anchorY=e.anchorY||e.height/2,this.rotation=e.rotation,this.boundingBox=e.boundingBox,this.width=e.width,this.height=e.height,this.scaleX=e.scaleX,this.scaleY=e.scaleY,e.scale&&(this.scale=e.scale),this.visible=e.visible,this.opacity=e.opacity,this.clip=e.clip,this.clipX=e.clipX,this.clipY=e.clipY,this.backgroundColor=e.backgroundColor,this.overlayColor=e.overlayColor,this.compositeOperation=e.compositeOperation,this._image=null,this.imageX=e.imageX,this.imageY=e.imageY,this.flipHorizontal=e.flipHorizontal,this.flipVertical=e.flipVertical,this._savedProperties={},this.acceptInputEvents=e.acceptInputEvents,this.captureInputEvents=e.captureInputEvents,this.cancelInputEvents=e.cancelInputEvents,this.paused=e.paused,this.tickSpeed=e.tickSpeed,this.debug=e.debug,this.children=[],this._removedChildren=[],this.needsResort=!1,this.needsReflow=!1,this.layouts=e.layouts,this._tweenQueue=[],this._lastSortTick=0,this.autoSort=e.autoSort,this.autoSortDelay=e.autoSortDelay,this.recyclable=e.recyclable,e.image&&(this.image=e.image),e.bottom!==undefined&&(this.bottom=e.bottom),e.right!==undefined&&(this.right=e.right),e.parent&&e.parent.addChild(this),this._inputStartID=null},saveProperties:function(e,t){var n={};for(var r=0,i=t.length;r<i;++r){var s=t[r];n[s]=this[s]}return this._savedProperties[e]=n,this},loadProperties:function(e){var t=this._savedProperties[e];for(var e in t)this[e]=t[e];return this},getProperty:function(e,t){var n=this._savedProperties[e];return n[t]},set:function(e){for(var t in e)this[t]=e[t];return this},addChild:function(e){e.parent&&e.removeFromParent(),e.parent=this,this.children.push(e),this.needsResort=!0},removeChild:function(e){e.parent==this&&this._removedChildren.indexOf(e)==-1&&(e.parent=null,this._removedChildren.push(e))},getChildByTag:function(e){for(var t=0,n=this.children.length;t<n;++t){var r=this.children[t];if(r.tag==e)return r}return null},removeChildren:function(){for(var e=0,t=this.children.length;e<t;++e){var n=this.children[e];n.removeFromParent()}},removeFromParent:function(){this.parent&&this.parent.removeChild(this),this.fire("removedFromParent",[this])},destroy:function(){this.removeListeners(),this.cancelTween(),this.removeFromParent(),this.destroyChildren(),this.recyclable&&t.recycle(this)},destroyChildren:function(){var e=this.children;for(var t=0,n=e.length;t<n;++t){var r=e[t];r.destroy()}},sortChildren:function(){if(!this.autoSort)return;var e=o.tickCount;if(e-this._lastSortTick<this.autoSortDelay)return;this.children.sort(p),this.needsResort=!1,this._lastSortTick=e},reflow:function(){this.debug&&logger.info(this.tag+": Reflow");var e=this._getCurrentLayout();e!=null&&this.applyLayout(e);for(var t=0,n=this.children.length;t<n;++t)this.children[t].reflow();this.needsReflow=!1},applyLayout:function(e){this.set(e.conf),e.align&&this.align.apply(this,e.align);for(var t=0,n=this.children.length;t<n;++t){var r=this.children[t];e.children&&e.children[r.tag]&&r.applyLayout(e.children[r.tag])}},show:function(){return this.visible=!0,this},hide:function(){return this.visible=!1,this},toggle:function(){this.visible?this.hide():this.show()},intersects:function(e){return e instanceof t?f.intersects(e.boundingBox,this.boundingBox):e.width?f.intersects(e,this.boundingBox):f.pointInRect(e,this.boundingBox)},createBoundTimer:function(e,t){var n=new u({interval:e,tickHost:this});return n.on("elapsed",this,t),n},react:function(e){if(!this.canReact)return;if(this.captureInputEvents){var t={x:e.point.x-this.x,y:e.point.y-this.y};for(var n=this.children.length-1;n>=0;--n){var r=this.children[n];if(r.canReact&&r.intersects(t)){e.point.x=t.x,e.point.y=t.y,r.react(e);if(e.cancel===!0)return}}e.target||(e.target=this),e.point.x=t.x,e.point.y=t.y,this.fire(e.type,[e]),e.type==="inputStart"?this._inputStartID=e.id:e.type==="inputEnd"&&this._inputStartID===e.id&&(this.fire("inputPress",[e]),this._inputStartID=null)}this.cancelInputEvents&&(e.cancel=!0)},preTick:function(e){if(this.paused||!this.visible)return;var e=e*this.tickSpeed;this._cullChildren(),this._updateTween(e),this.tick&&this.tick(e),this.fire("tick",[e]);var t=this.children;for(var n=0,r=t.length;n<r;++n)t[n].preTick(e)},preRender:function(e){if(!this.visible||this.opacity<=0)return;this.needsResort&&this.sortChildren(),this.needsReflow&&this.reflow();var t=~~this.x,n=~~this.y,i=~~this.anchorX,s=~~this.anchorY;e.save();var o=this.compositeOpacity;o!==1&&(e.globalAlpha=o),this.compositeOperation&&(e.globalCompositeOperation=this.compositeOperation),e.translate(t+i,n+s),this.rotation!=0&&e.rotate(this.rotation),(this.scaleX!=1||this.scaleY!=1)&&e.scale(this.scaleX,this.scaleY);if(this.flipHorizontal||this.flipVertical){var u=this.flipHorizontal?-1:1,a=this.flipVertical?-1:1;e.scale(u,a)}e.translate(-i,-s),this.clip&&!r.isXDK&&(e.beginPath(),e.rect(0,0,this.width,this.height),e.clip(),e.closePath()),this.render&&this.width>0&&this.height>0&&(this.render(e),this.debug&&this._renderDebug(e)),this.renderChildren(e),e.restore()},renderChildren:function(e){var t=this.children;for(var n=0,r=t.length;n<r;++n){var i=t[n];if(i.parent!==this)continue;i.preRender(e)}},render:function(e){var t=e;this.overlayColor&&(this._makeBuffer(),t=this._bufferContext);if(this._image&&this._image.ready){var n=~~(this.clipY!==null?Math.min(this.clipY,this.height):this.height);t.drawImage(this._image,this.imageX,this.imageY,this.width,n,0,0,this.width,n)}else this.backgroundColor&&(t.fillStyle=this.backgroundColor,t.fillRect(0,0,this.width,this.height));this.overlayColor&&(t.globalCompositeOperation="source-atop",t.fillStyle=this.overlayColor,t.fillRect(0,0,this.width,this.height)),t!==e&&e.drawImage(this._bufferCanvas,0,0,this.width,this.height)},_makeBuffer:function(){if(this._bufferCanvas){this._bufferCanvas.width=this.width,this._bufferCanvas.height=this.height;return}this._bufferCanvas=a.createBuffer(this.width,this.height),this._bufferContext=this._bufferCanvas.getContext("2d")},align:function(e,t,n,r){if(!this.parent)return;if(e!==undefined&&e!==null){switch(e){case"left":this.x=0;break;case"right":this.right=this.parent.width;break;case"center":this.x=this.parent.width/2-this.width/2}this.x+=n||0}if(t!==undefined&&t!==null){switch(t){case"top":this.y=0;break;case"bottom":this.y=this.parent.height-this.height;break;case"center":this.y=this.parent.height/2-this.height/2}this.y+=r||0}return this},centerOn:function(e,t,n){typeof e=="number"&&logger.error("centerOn doesn't support numbers"),e.width=e.width||1,e.height=e.height||1;var r=e.x+e.width/2,i=e.y+e.height/2;return this.x=r-this.width/2+(t||0),this.y=i-this.height/2+(n||0),this},centerAnchor:function(){return this.anchorX=this.width/2,this.anchorY=this.height/2,this},tween:function(e,t,n,r){if(e!=null)for(var i in e){var s=e[i];typeof s!="object"&&(e[i]={from:null,to:s})}return this._tweenQueue.push({properties:e,duration:isNaN(t)?1e3:t,transition:n||c.linear,callback:r||null,elapsed:0}),this.visible||(logger.info(this.tag+": Auto-completing tween because this view is invisible"),this.completeTween()),this},delayTween:function(e,t){return this.tween(null,e,null,t)},cancelTween:function(e){return this._tweenQueue=[],e&&this.set(e),this},completeTween:function(e){var t=this._tweenQueue.length,n=this._tweenQueue.splice(0,t);for(var r=0;r<t;++r){var i=n[r];for(var s in i.properties)this[s]=i.properties[s].to;i.callback&&i.callback()}return e&&this.set(e),this},_updateTween:function(e){var t=this._tweenQueue,n=function(){var e=t.shift();e.callback&&e.callback()};while(e>0&&t.length>0){var r=t[0],i=r.duration-r.elapsed,s=Math.min(e,i);r.elapsed+=s,e-=s;if(r.properties===null){r.elapsed>=r.duration&&n();continue}if(r.elapsed>=r.duration||r.duration<=0){for(var o in r.properties)this[o]=r.properties[o].to;n()}else for(var o in r.properties){var u=r.properties[o];u.from==null&&(u.from=this[o]);var a=r.transition(r.elapsed,u.from,u.to-u.from,r.duration);this[o]=a}}},_cullChildren:function(){var e=this._removedChildren,t=e.length;if(t<1)return;var n=this.children;for(var r=0;r<t;++r){var i=e[r],s=n.indexOf(i);s!=-1?n.splice(s,1):logger.warn("Tried to remove non-child "+i.tag+" from "+this.tag)}e.splice(0,t)},_getCurrentLayout:function(){var e=a.width+"x"+a.height;return this._layouts&&this._layouts[e]?this._layouts[e]:null},_initLayouts:function(){if(this._layouts==null)return;var e=this._layouts.init,n=e?e.conf||{}:{},r=this._getCurrentLayout();r&&r.conf&&(n=merge(r.conf,n)),this.set(n);if(e&&e.children)for(var i in e.children){var s=e.children[i],o=s.conf||{},u=this._getCurrentLayout(),a=null;u!=null&&u.children&&u.children[i]&&(a=u.children[i],o=merge(a.conf,o));var f=s.ctor||t,l=new f(merge({parent:this,tag:i},o));a&&a.align&&l.align.apply(l,a.align)}this.reflow()},_renderDebug:function(e){e.lineWidth=1;var t=this.boundingBox,n=t.x-this.x,r=t.y-this.y;e.fillStyle="rgba(255, 0, 0, 0.15)",e.fillRect(n,r,t.width,t.height),e.strokeStyle="rgb(255, 0, 0)",e.strokeRect(n,r,t.width,t.height),e.strokeStyle="rgb(0, 0, 255)",e.strokeRect(0,0,this.width,this.height)}});t.transitions=c,Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},set:function(e){this.x=e-this.width}}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},set:function(e){this.y=e-this.height}}),Object.defineProperty(t.prototype,"z",{get:function(){return this._z},set:function(e){if(this._z===e)return;this._z=e,this.parent&&(this.parent.needsResort=!0)}}),Object.defineProperty(t.prototype,"scale",{get:function(){return Math.max(this.scaleX,this.scaleY)},set:function(e){this.scaleX=e,this.scaleY=e}}),Object.defineProperty(t.prototype,"scaleWidth",{get:function(){return this.width*this.scaleX}}),Object.defineProperty(t.prototype,"scaleHeight",{get:function(){return this.height*this.scaleY}}),Object.defineProperty(t.prototype,"image",{set:function(e){this._image=s.get(e)}}),Object.defineProperty(t.prototype,"center",{get:function(){return{x:this.x+this.width/2,y:this.y+this.height/2}}}),Object.defineProperty(t.prototype,"boundingBox",{get:function(){var e=this._boundingBox;return e==null?{x:this.x,y:this.y,width:this.width,height:this.height}:{x:this.x+e.x,y:this.y+e.y,width:e.width,height:e.height}},set:function(e){this._boundingBox=e}}),Object.defineProperty(t.prototype,"compositeOpacity",{get:function(){var e=this.parent?this.parent.compositeOpacity:1;return this.opacity*e}}),Object.defineProperty(t.prototype,"layouts",{set:function(e){this._layouts=e,this._initLayouts()}}),Object.defineProperty(t.prototype,"canReact",{get:function(){return this.acceptInputEvents&&this.visible&&!this.paused}}),Object.defineProperty(t.prototype,"absolutePosition",{get:function(){var e=this.x,n=this.y,r=this;while(r.parent instanceof t)r=r.parent,e+=r.x,n+=r.y;return{x:e,y:n}}});var d={};t.create=function(e,t){var n=e.uid,r=d[n];if(r&&r.length>0){var i=r.shift();return i.init(t),i}return new e(t)},t.recycle=function(e){var t=e.constructor.uid,n=d[t];n||(n=d[t]=[]),n.push(e)},t.defaults={parent:null,x:0,y:0,z:1,anchorX:null,anchorY:null,clipX:null,clipY:null,boundingBox:null,acceptInputEvents:!1,captureInputEvents:!0,cancelInputEvents:!1,debug:!1,layouts:null,rotation:0,recyclable:!1,clip:!1,width:0,height:0,scaleX:1,scaleY:1,visible:!0,opacity:1,backgroundColor:null,overlayColor:null,compositeOperation:null,image:null,imageX:0,imageY:0,paused:!1,tickSpeed:1,flipHorizontal:!1,flipVertical:!1,autoSort:!0,autoSortDelay:1}}),define("djinn/TextView",["require","exports","module","./View"],function(e,t,n){var r=e("./View"),t=n.exports=r.extend({init:function(e){e=merge(e,t.defaults),e.parent&&(!e.width||e.width<1)&&(e.width=e.parent.width);if(!e.height||e.height<1)e.height=e.fontSize;this._super(e),this._lineBuffer=null,this._rawText=null,this.color=e.color,this.fontSize=e.fontSize,this.fontFamily=e.fontFamily,this.shadowColor=e.shadowColor,this.shadowX=e.shadowX,this.shadowY=e.shadowY,this.strokeColor=e.strokeColor,this.strokeWidth=e.strokeWidth,this.textAlign=e.textAlign,this.verticalAlign=e.verticalAlign,this.wordWrap=e.wordWrap,this.autoSize=e.autoSize,this.text=e.text},render:function(e){this._super(e);if(this.text===undefined||this.text===null||this.text.length<1)return;this._lineBuffer==null&&this._bufferLines(this.text,e);var t=0,n=0;this.textAlign=="center"&&(t=this.width/2),this.textAlign=="right"&&(t=this.width),this.verticalAlign=="middle"&&(n=this.height/2),this._applyContextSettings(e);var r=e.measureText(this._rawText),i=~~r.width;this.autoSize&&i!==this.width&&(this.width=i,this.height=this.fontSize,this.fire("autoSize"));for(var s=0,o=this._lineBuffer.length;s<o;++s){var u=n+s*this.fontSize,a=this._lineBuffer[s];this.shadowColor&&(e.fillStyle=this.shadowColor,e.fillText(a,t+this.shadowX,u+this.shadowY)),this.strokeColor&&this.strokeWidth&&(e.lineWidth=this.strokeWidth,e.strokeStyle=this.strokeColor,e.strokeText(a,t,u)),e.fillStyle=this.color,e.fillText(a,t,u)}},_applyContextSettings:function(e){var t=sprintf("%spx %s",this.fontSize,this.fontFamily);e.font=t,e.textAlign=this.textAlign,e.textBaseline=this.verticalAlign,e.lineWidth=this.strokeWidth},_bufferLines:function(e,t){var e=String(e);this._lineBuffer=[];if(this.wordWrap){this._applyContextSettings(t);var n=e.split(" "),r=0;for(var i=0,s=n.length;i<s;++i){var o=this._lineBuffer[r]||"",u=o.length>0?o+" "+n[i]:n[i];o.length>0&&t.measureText(u).width>this.width?(++r,this._lineBuffer[r]=n[i]):this._lineBuffer[r]=u}}else this._lineBuffer.push(e)}});Object.defineProperty(t.prototype,"text",{get:function(){return this._rawText},set:function(e){this._lineBuffer=null,this._rawText=e===undefined?null:String(e)}}),t.defaults={color:"rgb(0, 0, 0)",fontFamily:"Arial",fontSize:20,shadowColor:null,shadowX:1,shadowY:1,strokeColor:null,strokeWidth:null,text:"",textAlign:"left",verticalAlign:"top",wordWrap:!0,autoSize:!1}}),define("djinn/helpers/RotateDeviceView",["djinn/View","djinn/TextView","djinn/manifest"],function(e,t,n){var r="%s works best in %s orientation. Please rotate your device.",i=e.extend({init:function(e){var e=merge(e,i.defaults);this._super(e),this._message=new t({parent:this,textAlign:"center",color:"white",fontSize:50,text:sprintf(r,n.title,n.orientation)}),this.reflow()},reflow:function(){this.set({width:this.parent.width,height:this.parent.height}),this._message.set({width:this.width}).align("center","center"),this._super()}});return i.defaults={backgroundColor:"black",visible:!1,z:Infinity},i}),define("djinn/ui/ProgressBar",["djinn/View"],function(e){return e.extend({init:function(e){var e=merge(e,{progress:0});this._super(e),this.progress=Number(e.progress)},render:function(e){this._super(e);var t=this.width*this.progress;e.fillStyle="rgb(100, 100, 100)",e.fillRect(0,0,t,this.height),e.lineWidth=2,e.strokeStyle="rgb(230, 230, 230)",e.strokeRect(0,0,this.width,this.height)}})}),define("djinn/utils/viewEffects",["djinn/math/core","djinn/utils/transitions"],function(e,t){return{alert:function(e,n,r){var n=n||{},i=e.z;e.completeTween({z:Infinity}).tween({scale:n.scale||1.5},(n.duration||500)/2,t.easeBoth,function(){n.midCallback&&n.midCallback()}).tween({scale:1},(n.duration||500)/2,t.easeBoth,function(){e.z=i,r&&r()})},burst:function(e,n,r){e.completeTween({opacity:0,scale:.5}),e.tween({opacity:1,rotation:Math.PI/2,scale:1.5},100,t.linear).tween({opacity:0},100,t.linear,function(){r&&r()})},buttonPress:function(e,n,r){e.completeTween().tween({y:e.y+e.height/10},50,t.linear).tween({y:e.y},50,t.linear,r)},fadeOut:function(e,n,r){var n=n||{};e.completeTween().tween({opacity:0},n.duration||500,t.linear,r)},fadeIn:function(e,n,r){var n=n||{};e.completeTween().tween({opacity:1},n.duration||500,t.linear,r)},fadeInAndOut:function(e,t,n){var t=t||{},r=(t.duration||1e3)/2;e.completeTween({opacity:0,visible:!0}),e.tween({opacity:t.opacity||1},r).tween({opacity:0},r,null,n)},popIn:function(n,r,i){var r=r||{},s=e.random(1,2)==1?2:-2,o=e.clamp(n.x+n.width*s,0,n.parent.width-n.width),u=n.y;n.completeTween({opacity:r.opacity||0,scale:r.scale||.5}),n.y+=n.height/2,n.tween({opacity:1,scale:1,x:o,y:u},200,t.linear).tween({scale:1.25},50,t.linear).tween({scale:1},50,t.linear,i)},popOut:function(e,n,r){e.completeTween({opacity:1}).tween({scale:.75},50,t.linear).tween({opacity:0,scale:2},250,t.linear,r)},shake:function(e,t,n){e.completeTween();var t=t||{},r=t.iterations||10,i=(t.duration||250)/r,s=t.violence||6,o=e.x,u=e.y;for(var a=0;a<r;++a)e.tween({x:e.x+s*(a%2?1:-1)},i);e.delayTween(0,function(){e.x=o,e.y=u,n&&n()})},squishyAppear:function(e,n,r){var n=n||{},i=n.duration||500,s=n.scale||1;e.completeTween({scaleX:2*s,scaleY:0}),e.tween({scaleX:.5*s,scaleY:2*s},i*.3,t.linear).tween({scaleX:s,scaleY:s},i*.7,t.elasticOut,function(){r&&r()})},squishyDisappear:function(e,n,r){var n=n||{},i=n.duration||500,s=n.scale||1;e.completeTween({scaleX:s,scaleY:s}),e.tween({scaleX:.5*s,scaleY:2*s},i*.3,t.linear).tween({scaleX:2*s,scaleY:0},i*.7,t.elasticOut,function(){r&&r()})},vibrate:function(t,n,r){t.completeTween();var n=n||{},i=n.iterations||10,s=(n.duration||250)/i,o=n.violence||6,u=t.x,a=t.y;for(var f=0;f<i;++f)t.tween({x:t.x+e.random(-o,o),y:t.y+e.random(-o,o)},s);t.delayTween(1,function(){t.x=u,t.y=a,r&&r()})}}}),define("djinn/helpers/LoadingScreen",["djinn/manifest","djinn/assets","djinn/View","djinn/TextView","djinn/ui/ProgressBar","djinn/utils/viewEffects","djinn/stage"],function(e,t,n,r,i,s,o){var u=merge(e.splash,{fadeDuration:1,displayDuration:0,backgroundColor:"rgb(0, 0, 0)",imageWidth:100,imageHeight:100});return n.extend({init:function(e){Object.defineProperty(this,"loadingProgress",{set:function(e){this._loadingBar.progress=e,this._loadingText.text="LOADING: "+~~(e*100)+"%"}});var e=merge({tag:"LoadingScreen",acceptInputEvents:!0,cancelInputEvents:!0,visible:!1,backgroundColor:u.backgroundColor,z:Infinity},e);this._super(e);if(u.images&&u.images.length>0){var s=u.images[o.sizeIndex];t.load(s.image),this._splashImage=(new n(merge({parent:this},s))).align("center","center")}var a=this.height*.05;this._loadingBar=(new i({parent:this,visible:!1,width:this.width*.8,height:a})).align("center","bottom",0,-a),this._loadingText=(new r({parent:this,visible:!1,text:"LOADING",textAlign:"center",verticalAlign:"middle",color:"rgb(255, 255, 255)",fontSize:~~(a*.75),height:a})).align("center","bottom",0,-a),this._uiDelayTimer=this.createBoundTimer(500,bind(this,"_onDelayElapsed")),this.on("inputStart",this,"_onInputStart")},show:function(e){this.set({opacity:0,visible:!0}),s.fadeIn(this,{duration:u.fadeDuration}),this.delayTween(u.displayDuration,function(){e&&e()}),this._uiDelayTimer.start()},hide:function(e){this.acceptInputEvents=!1,s.fadeOut(this,{duration:u.fadeDuration},bind(this,function(){this.visible=!1,e&&e()}))},_onDelayElapsed:function(){this._uiDelayTimer.stop(),this._loadingBar.progress<1&&(this._loadingText.visible=!0,this._loadingBar.visible=!0)},_onInputStart:function(e){this._onDelayElapsed(),this.completeTween()}})}),define("djinn/Collection",["djinn/utils/array","djinn/Emitter"],function(e,t){var n=t.extend({init:function(e){this._super(e),this.items=[],this._itemIDSeed=0,this._lookup={},this._length=0,this._indexPool=[]},add:function(e){typeof e.id=="undefined"&&(e.id=++this._itemIDSeed);if(this.has(e.id))return logger.warn("[Collection.add] Item ID conflict: "+e.id),null;if(this._indexPool.length>0){var t=this._indexPool.shift();this.items[t]=e}else{this._length=this.items.push(e);var t=this._length-1}return this._lookup[e.id]=t,this.fire("add",[e]),e.id},remove:function(e,t){var n=e.id||e,r=this._getIndex(n);if(!this._isValidIndex(r))return logger.warn("[Collection.remove] Tried to remove invalid item: "+n),null;var e=this.items[r];return this.items[r]=null,delete this._lookup[n],this._indexPool.push(r),t&&e.removeListeners&&e.removeListeners(),this.fire("remove",[e]),e},has:function(e){return this.get(e)!==null},get:function(e){var t=this._getIndex(e);if(isNaN(t)||t>=this._length)return null;var n=this.items[t]||null;return n},forEach:function(e,t){for(var n=0;n<this._length;++n){var r=this.items[n];if(r===null)continue;t?e.call(t,r,this):e(r,this)}},sort:function(){this.items.sort(function(e,t){return e?t?t.id-e.id:-1:1}),this._rebuild()},pickRandom:function(){return e.pickRandom(this.items)},removeAll:function(e){this.forEach(function(t,n){if(!t)return;this.remove(t.id,e)},this),this.items=[],this._lookup={},this._indexPool=[],this._length=0},_getIndex:function(e){return this._lookup[e]},_isValidIndex:function(e){return e>=0&&e<this._length},_rebuild:function(){this._lookup={},this._indexPool=[];for(var e=0,t=this.items.length;e<t;++e){var n=this.items[e];n?this._lookup[n.id]=e:this._indexPool.push(e)}}});return Object.defineProperty(n.prototype,"length",{get:function(){return this._length}}),n}),function(){var e={},t=null,n=!0,r=!1;if(typeof AudioContext!="undefined")t=new AudioContext;else if(typeof webkitAudioContext!="undefined")t=new webkitAudioContext;else if(typeof Audio!="undefined"){n=!1;try{new Audio}catch(i){r=!0}}else n=!1,r=!0;if(n){var s=typeof t.createGain=="undefined"?t.createGainNode():t.createGain();s.gain.value=1,s.connect(t.destination)}var o=function(){this._volume=1,this._muted=!1,this.usingWebAudio=n,this._howls=[]};o.prototype={volume:function(e){var t=this;e=parseFloat(e);if(e&&e>=0&&e<=1){t._volume=e,n&&(s.gain.value=e);for(var r in t._howls)if(t._howls.hasOwnProperty(r)&&t._howls[r]._webAudio===!1)for(var i=0;i<t._howls[r]._audioNode.length;i++)t._howls[r]._audioNode[i].volume=t._howls[r]._volume*t._volume;return t}return n?s.gain.value:t._volume},mute:function(){return this._setMuted(!0),this},unmute:function(){return this._setMuted(!1),this},_setMuted:function(e){var t=this;t._muted=e,n&&(s.gain.value=e?0:t._volume);for(var r in t._howls)if(t._howls.hasOwnProperty(r)&&t._howls[r]._webAudio===!1)for(var i=0;i<t._howls[r]._audioNode.length;i++)t._howls[r]._audioNode[i].muted=e}};var u=new o,a=null;if(!r){a=new Audio;var f={mp3:!!a.canPlayType("audio/mpeg;").replace(/^no$/,""),opus:!!a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),m4a:!!(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")}}var l=function(e){var t=this;t._autoplay=e.autoplay||!1,t._buffer=e.buffer||!1,t._duration=e.duration||0,t._format=e.format||null,t._loop=e.loop||!1,t._loaded=!1,t._sprite=e.sprite||{},t._src=e.src||"",t._pos3d=e.pos3d||[0,0,-0.5],t._volume=e.volume||1,t._urls=e.urls||[],t._rate=e.rate||1,t._onload=[e.onload||function(){}],t._onloaderror=[e.onloaderror||function(){}],t._onend=[e.onend||function(){}],t._onpause=[e.onpause||function(){}],t._onplay=[e.onplay||function(){}],t._onendTimer=[],t._webAudio=n&&!t._buffer,t._audioNode=[],t._webAudio&&t._setupAudioNode(),u._howls.push(t),t.load()};l.prototype={load:function(){var t=this,n=null;if(r){t.on("loaderror");return}for(var i=0;i<t._urls.length;i++){var s,o;if(t._format)s=t._format;else{o=t._urls[i].toLowerCase().split("?")[0],s=o.match(/.+\.([^?]+)(\?|$)/),s=s&&s.length>=2?s:o.match(/data\:audio\/([^?]+);/);if(!s){t.on("loaderror");return}s=s[1]}if(f[s]){n=t._urls[i];break}}if(!n){t.on("loaderror");return}t._src=n;if(t._webAudio)c(t,n);else{var a=new Audio;t._audioNode.push(a),a.src=n,a._pos=0,a.preload="auto",a.volume=u._muted?0:t._volume*u.volume(),e[n]=t;var l=function(){t._duration=a.duration,Object.getOwnPropertyNames(t._sprite).length===0&&(t._sprite={_default:[0,t._duration*1e3]}),t._loaded||(t._loaded=!0,t.on("load")),t._autoplay&&t.play(),a.removeEventListener("canplaythrough",l,!1)};a.addEventListener("canplaythrough",l,!1),a.load()}return t},urls:function(e){var t=this;return e?(t.stop(),t._urls=typeof e=="string"?[e]:e,t._loaded=!1,t.load(),t):t._urls},play:function(e,n){var r=this;typeof e=="function"&&(n=e);if(!e||typeof e=="function")e="_default";return r._loaded?r._sprite[e]?(r._inactiveNode(function(i){i._sprite=e;var s=i._pos>0?i._pos:r._sprite[e][0]/1e3,o=r._sprite[e][1]/1e3-i._pos,a=!!r._loop||!!r._sprite[e][2],f=typeof n=="string"?n:Math.round(Date.now()*Math.random())+"",l;(function(){var t={id:f,sprite:e,loop:a};l=setTimeout(function(){!r._webAudio&&a&&r.stop(t.id,t.timer).play(e,t.id),r._webAudio&&!a&&(r._nodeById(t.id).paused=!0),!r._webAudio&&!a&&r.stop(t.id,t.timer),r.on("end",f)},o*1e3),r._onendTimer.push(l),t.timer=r._onendTimer[r._onendTimer.length-1]})();if(r._webAudio){var c=r._sprite[e][0]/1e3,h=r._sprite[e][1]/1e3;i.id=f,i.paused=!1,p(r,[a,c,h],f),r._playStart=t.currentTime,i.gain.value=r._volume,typeof i.bufferSource.start=="undefined"?i.bufferSource.noteGrainOn(0,s,o):i.bufferSource.start(0,s,o)}else{if(i.readyState!==4)return r._clearEndTimer(l),function(){var t=r,s=e,o=n,u=i,a=function(){t.play(s,o),u.removeEventListener("canplaythrough",a,!1)};u.addEventListener("canplaythrough",a,!1)}(),r;i.id=f,i.currentTime=s,i.muted=u._muted,i.volume=r._volume*u.volume(),setTimeout(function(){i.play()},0)}return r.on("play"),typeof n=="function"&&n(f),r}),r):(typeof n=="function"&&n(),r):(r.on("load",function(){r.play(e,n)}),r)},pause:function(e,t){var n=this;if(!n._loaded)return n.on("play",function(){n.pause(e)}),n;n._clearEndTimer(t||0);var r=e?n._nodeById(e):n._activeNode();if(r){r._pos=n.pos(null,e);if(n._webAudio){if(!r.bufferSource)return n;r.paused=!0,typeof r.bufferSource.stop=="undefined"?r.bufferSource.noteOff(0):r.bufferSource.stop(0)}else r.pause()}return n.on("pause"),n},stop:function(e,t){var n=this;if(!n._loaded)return n.on("play",function(){n.stop(e)}),n;n._clearEndTimer(t||0);var r=e?n._nodeById(e):n._activeNode();if(r){r._pos=0;if(n._webAudio){if(!r.bufferSource)return n;r.paused=!0,typeof r.bufferSource.stop=="undefined"?r.bufferSource.noteOff(0):r.bufferSource.stop(0)}else r.pause(),r.currentTime=0}return n},mute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.mute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=0:n.volume=0),t},unmute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.unmute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=t._volume:n.volume=t._volume),t},volume:function(e,t){var n=this;e=parseFloat(e);if(e>=0&&e<=1){n._volume=e;if(!n._loaded)return n.on("play",function(){n.volume(e,t)}),n;var r=t?n._nodeById(t):n._activeNode();return r&&(n._webAudio?r.gain.value=e:r.volume=e*u.volume()),n}return n._volume},loop:function(e){var t=this;return typeof e=="boolean"?(t._loop=e,t):t._loop},sprite:function(e){var t=this;return typeof e=="object"?(t._sprite=e,t):t._sprite},pos:function(e,n){var r=this;if(!r._loaded)return r.on("load",function(){r.pos(e)}),typeof e=="number"?r:r._pos||0;e=parseFloat(e);var i=n?r._nodeById(n):r._activeNode();if(i)return r._webAudio?e>=0?(i._pos=e,r.pause(n).play(i._sprite,n),r):i._pos+(t.currentTime-r._playStart):e>=0?(i.currentTime=e,r):i.currentTime;if(e>=0)return r;for(var s=0;s<r._audioNode.length;s++)if(r._audioNode[s].paused&&r._audioNode[s].readyState===4)return r._webAudio?r._audioNode[s]._pos:r._audioNode[s].currentTime},pos3d:function(e,t,n,r){var i=this;t=typeof t=="undefined"||!t?0:t,n=typeof n=="undefined"||!n?-0.5:n;if(!i._loaded)return i.on("play",function(){i.pos3d(e,t,n,r)}),i;if(e>=0||e<0){if(i._webAudio){var s=r?i._nodeById(r):i._activeNode();s&&(i._pos3d=[e,t,n],s.panner.setPosition(e,t,n))}return i}return i._pos3d},fade:function(e,t,n,r,i){var s=this,o=Math.abs(e-t),u=e>t?"down":"up",a=o/.01,f=n/a;if(!s._loaded)return s.on("load",function(){s.fade(e,t,n,r,i)}),s;s.volume(e,i);for(var l=1;l<=a;l++)(function(){var e=s._volume+(u==="up"?.01:-0.01)*l,n=Math.round(1e3*e)/1e3,o=t;setTimeout(function(){s.volume(n,i),n===o&&r&&r()},f*l)})()},fadeIn:function(e,t,n){return this.volume(0).play().fade(0,e,t,n)},fadeOut:function(e,t,n,r){var i=this;return i.fade(i._volume,e,t,function(){n&&n(),i.pause(r),i.on("end")},r)},_nodeById:function(e){var t=this,n=t._audioNode[0];for(var r=0;r<t._audioNode.length;r++)if(t._audioNode[r].id===e){n=t._audioNode[r];break}return n},_activeNode:function(){var e=this,t=null;for(var n=0;n<e._audioNode.length;n++)if(!e._audioNode[n].paused){t=e._audioNode[n];break}return e._drainPool(),t},_inactiveNode:function(e){var t=this,n=null;for(var r=0;r<t._audioNode.length;r++)if(t._audioNode[r].paused&&t._audioNode[r].readyState===4){e(t._audioNode[r]),n=!0;break}t._drainPool();if(n)return;var i;t._webAudio?(i=t._setupAudioNode(),e(i)):(t.load(),i=t._audioNode[t._audioNode.length-1],i.addEventListener("loadedmetadata",function(){e(i)}))},_drainPool:function(){var e=this,t=0,n;for(n=0;n<e._audioNode.length;n++)e._audioNode[n].paused&&t++;for(n=e._audioNode.length-1;n>=0;n--){if(t<=5)break;e._audioNode[n].paused&&(e._webAudio&&e._audioNode[n].disconnect(0),t--,e._audioNode.splice(n,1))}},_clearEndTimer:function(e){var t=this,n=t._onendTimer.indexOf(e);n=n>=0?n:0,t._onendTimer[n]&&(clearTimeout(t._onendTimer[n]),t._onendTimer.splice(n,1))},_setupAudioNode:function(){var e=this,n=e._audioNode,r=e._audioNode.length;return n[r]=typeof t.createGain=="undefined"?t.createGainNode():t.createGain(),n[r].gain.value=e._volume,n[r].paused=!0,n[r]._pos=0,n[r].readyState=4,n[r].connect(s),n[r].panner=t.createPanner(),n[r].panner.setPosition(e._pos3d[0],e._pos3d[1],e._pos3d[2]),n[r].panner.connect(n[r]),n[r]},on:function(e,t){var n=this,r=n["_on"+e];if(typeof t=="function")r.push(t);else for(var i=0;i<r.length;i++)t?r[i].call(n,t):r[i].call(n);return n},off:function(e,t){var n=this,r=n["_on"+e],i=t.toString();for(var s=0;s<r.length;s++)if(i===r[s].toString()){r.splice(s,1);break}return n},unload:function(){var t=this,n=t._audioNode;for(var r=0;r<t._audioNode.length;r++)t.stop(n[r].id),t._webAudio?n[r].disconnect(0):n[r].src="";var i=u._howls.indexOf(t);i&&u._howls.splice(i,1),delete e[t._src],t=null}};if(n)var c=function(n,r){if(r in e)n._duration=e[r].duration,h(n);else{var i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="arraybuffer",i.onload=function(){t.decodeAudioData(i.response,function(t){t&&(e[r]=t,h(n,t))})},i.onerror=function(){n._webAudio&&(n._buffer=!0,n._webAudio=!1,n._audioNode=[],delete n._gainNode,n.load())};try{i.send()}catch(s){i.onerror()}}},h=function(e,t){e._duration=t?t.duration:e._duration,Object.getOwnPropertyNames(e._sprite).length===0&&(e._sprite={_default:[0,e._duration*1e3]}),e._loaded||(e._loaded=!0,e.on("load")),e._autoplay&&e.play()},p=function(n,r,i){var s=n._nodeById(i);s.bufferSource=t.createBufferSource(),s.bufferSource.buffer=e[n._src],s.bufferSource.connect(s.panner),s.bufferSource.loop=r[0],r[0]&&(s.bufferSource.loopStart=r[1],s.bufferSource.loopEnd=r[1]+r[2]),s.bufferSource.playbackRate.value=n._rate};typeof define=="function"&&define.amd&&define("djinn/audio/howler",[],function(){return{Howler:u,Howl:l}}),window.Howler=u,window.Howl=l}(),define("djinn/utils/base64",[],function(){var e={};return e.supported=Boolean(window.btoa&&window.atob),e.encode=function(e,t){return window.btoa?btoa(unescape(encodeURIComponent(String(e)))):e},e.decode=function(e,t){if(!window.atob)return e;try{e=decodeURIComponent(escape(atob(String(e))))}catch(n){logger.warn("[base64.decode] Could not decode: "+e),logger.warn("[base64.decode] "+n.message)}return e},e}),define("djinn/utils/crypt",["djinn/utils/base64"],function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="`1234567890-=[];',./~!@#$%^&*()_+{}|:<>?QWERTYUIOPASDFGHJKLZXCVBN",r=n.length,i=function(e){return e?e.length%r:0},s={};return s.encode=function(s,o){if(!e.supported)return s;var u=i(o),s=e.encode(s),a="";for(var f=0,l=s.length;f<l;++f){var c=t.indexOf(s[f]),h=(c+u)%r;a+=n[h]}return a},s.decode=function(s,o){if(!e.supported)return s;var u=i(o),a="";for(var f=0,l=s.length;f<l;++f){var c=n.indexOf(s[f]),h=c-u;h<0&&(h=r+h),a+=t[h]}return e.decode(a)},s}),define("djinn/utils/storage",["djinn/utils/crypt"],function(e){var t={};return t.set=function(t,n){var t=e.encode(t,t),n=e.encode(n,t);try{localStorage.setItem(t,n)}catch(r){logger.warn("[storage.set] Failed to set localStorage! Quota exceeded?"),logger.warn("[storage.set] "+r.message)}},t.get=function(t){var t=e.encode(t,t),n=null;try{n=localStorage.getItem(t)}catch(r){logger.warn("[storage.get] Failed to get: "+t),logger.warn("[storage.get] "+r.message)}return n&&(n=e.decode(n,t)),n},t.remove=function(t){var t=e.encode(t,t);try{localStorage.removeItem(t)}catch(n){logger.warn("[storage.remove] Failed to remove: "+t),logger.warn("[storage.remove] "+n.message)}},t.setObject=function(e,n){var r=JSON.stringify(n);return t.set(e,r)},t.getObject=function(e){var n=t.get(e),r=null;try{r=JSON.parse(n)}catch(i){logger.warn("[storage.getObject] Could not parse JSON: "+n),logger.warn("[storage.getObject] "+i.message)}return r},t}),define("djinn/utils/DataStore",["require","exports","module","../Emitter","./storage"],function(e,t,n){var r=e("../Emitter"),i=e("./storage"),t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.key=e.key,this.load();if(e.defaults)for(var n in e.defaults){if(typeof this.data[n]!="undefined")continue;this.data[n]=e.defaults[n]}},load:function(){if(this.key){var e=i.getObject(this.key);this.data=e||{}}else this.data={}},save:function(){if(!this.key)return;i.setObject(this.key,this.data)},set:function(e,t){this.data[e]=t,this.save(),this.fire("set:"+e,[t])},get:function(e,t){var n=this.data[e];return n!==undefined?n:t},toggle:function(e){this.set(e,!this.get(e))},increment:function(e,t){var t=t||1,n=this.get(e,0);this.set(e,n+t)}});t.defaults={key:null}}),define("djinn/audio/jukebox",["require","exports","module","./howler","../Emitter","../stage","../client","../math/core","../utils/DataStore","../utils/array"],function(e,t,n){var r=e("./howler"),i=e("../Emitter"),s=e("../stage"),o=e("../client"),u=e("../math/core"),a=e("../utils/DataStore"),f=e("../utils/array"),l=r.Howler,c=r.Howl,h=i.extend({init:function(e){this._super(e),this.audioData=null,this.sounds={},this._inputTriggerKey=null,this._inputTriggerLoaded=!1,this._inputTriggerPlayed=!1,this._unmuteOnShow=!1,this._queue=[];var t=this.settings=new a({key:"jukebox_settings",defaults:{muted:!1,musicVolume:.5,soundVolume:.5}});t.get("muted")&&this.mute(),o.on("visibilityChange",this,"_onClientVisibilityChange"),s.on("input",this,"_onStageInput")},configure:function(e){this.audioData=e,e.inputTriggerKey&&(this._inputTriggerKey=e.inputTriggerKey,this.load(this._inputTriggerKey,bind(this,"_onInputTriggerLoad")))},mute:function(){l.mute(),this.settings.set("muted",!0),this.fire("mute")},unmute:function(){l.unmute(),this.settings.set("muted",!1),this.fire("unmute")},toggleMute:function(){this.muted=!this.muted},load:function(e,t){var n=this.sounds;if(n[e])return n[e];var r=this._getAudioData(e);if(!r)return;var i=[r.path+".ogg",r.path+".mp3"],s=n[e]=new c({urls:i,loop:r.loop,onload:function(){t&&t()},onloaderror:function(){logger.warn("[jukebox.load] Failed to load: "+e)}});return s.volume(this._getVolumeByType(r.type)),s},play:function(e){if(!this.canPlay){this._queue.push(e);return}var t=this._getSound(e,!0);if(!t)return;t.play()},pause:function(e){var t=this._getSound(e);if(!t)return;var n=this._getAudioData(e);n&&n.loop?t.stop():t.pause()},stop:function(e){var t=this._getSound(e);if(!t)return;t.stop()},fadeIn:function(e,t){var n=this._getAudioData(e);if(!n)return;if(!this.canPlay){n.loop&&this._queue.push(e);return}var r=this._getSound(e,!0);if(!r)return;r.play().fade(0,this._getVolumeByType(n.type),t)},fadeOut:function(e,t){var n=this._getSound(e);if(!n)return;n.fade(n.volume(),0,t)},setVolume:function(e,t){var n=this._getSound(e);if(!n)return;n.volume(t,e)},_getAudioData:function(e){var t=this.audioData;return t&&t.sounds&&t.sounds[e]?t.sounds[e]:(logger.warn("[jukebox._getAudioData] No audio data: "+e),null)},_getSound:function(e,t){var n=this.sounds;if(n&&n[e])return n[e];if(t){var r=this.load(e);return r?r:(logger.warn("[jukebox._getSound] Unable to load sound: "+e),null)}return null},_getVolumeByType:function(e){switch(e){case"music":return this.musicVolume;default:return this.soundVolume}},_changeVolumeByType:function(e,t){var n=this.sounds;for(var r in n){var i=n[r],s=this._getAudioData(r);if(!f.contains(e,s.type))continue;i.volume(t)}},_onClientVisibilityChange:function(e){e?this.muted||(this.mute(),this._unmuteOnShow=!0):this._unmuteOnShow&&(this.unmute(),this._unmuteOnShow=!1)},_onInputTriggerLoad:function(){this._inputTriggerLoaded=!0},_onStageInput:function(e){if(this._inputTriggerPlayed||!this._inputTriggerLoaded)return;this.play(this._inputTriggerKey),this.stop(this._inputTriggerKey),this._inputTriggerPlayed=!0;while(this._queue.length>0){var t=this._queue.shift();this.play(t)}}}),p=h.prototype;Object.defineProperty(p,"canPlay",{get:function(){return!o.isTouch||this._inputTriggerPlayed}}),Object.defineProperty(p,"muted",{get:function(){return l._muted},set:function(e){e?this.mute():this.unmute()}}),Object.defineProperty(p,"musicVolume",{get:function(){return this.settings.get("musicVolume")},set:function(e){var e=u.clamp(e,0,1);this.settings.set("musicVolume",e),this._changeVolumeByType(["music"],e)}}),Object.defineProperty(p,"soundVolume",{get:function(){return this.settings.get("soundVolume")},set:function(e){var e=u.clamp(e,0,1);this.settings.set("soundVolume",e),this._changeVolumeByType([undefined,"sound"],e)}}),n.exports=new h}),define("djinn/Scene",["require","exports","module","./View","./audio/jukebox"],function(e,t,n){var r=e("./View"),i=e("./audio/jukebox"),t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.musicKey=e.musicKey,this._isSetup=!1},setup:function(){},reset:function(){},activate:function(e){this.musicKey&&i.fadeIn(this.musicKey,500),this.captureInputEvents=!0},deactivate:function(e){this.musicKey&&i.fadeOut(this.musicKey,500),this.captureInputEvents=!1},cleanup:function(){this.musicKey&&i.stop(this.musicKey)},fireSceneEvent:function(e){var t={id:this.id,eventName:e};this.fire(e,[t])}});t.defaults={acceptInputEvents:!0,cancelInputEvents:!0,clip:!0,opacity:0,visible:!1,musicKey:null}}),define("djinn/masks/SpotlightMaskView",["djinn/View","djinn/stage"],function(e,t){var n=["width","height","spotlightX","spotlightY","spotlightRadius"];return e.extend({init:function(e){var e=merge(e,{backgroundColor:"rgb(0, 0, 0)",spotlightX:0,spotlightY:0,spotlightRadius:100});this._super(e),this._buffer=t.createBuffer(this.width,this.height),this._bufferDirty=!0,this.spotlightX=Number(e.spotlightX),this.spotlightY=Number(e.spotlightY),this.spotlightRadius=Number(e.spotlightRadius),this._cachedProps={},t.on("resize",this,function(){this._bufferDirty=!0})},render:function(e){var t=this._buffer;if(t.width!==this.width||t.height!==this.height)t.width=this.width,t.height=this.height,this._bufferDirty=!0;if(!this._bufferDirty)for(var r=0,i=n.length;r<i;++r){var s=n[r];if(this._cachedProps[s]!=this[s]){this._bufferDirty=!0;break}}if(this._bufferDirty){var o=t.getContext("2d");o.save(),o.clearRect(0,0,this.width,this.height),o.fillStyle=this.backgroundColor,o.fillRect(0,0,this.width,this.height),o.globalCompositeOperation="destination-out",o.beginPath(),o.arc(this.spotlightX,this.spotlightY,this.spotlightRadius,0,Math.PI*2,!0),o.fill(),o.closePath(),o.restore();for(var r=0,i=n.length;r<i;++r){var s=n[r];this._cachedProps[s]=this[s]}this._bufferDirty=!1}e.drawImage(this._buffer,0,0,this.width,this.height)}})}),define("djinn/utils/sceneTransitions",["require","exports","module","djinn/utils/transitions","djinn/masks/SpotlightMaskView"],function(e,t,n){var r=e("djinn/utils/transitions"),i=e("djinn/masks/SpotlightMaskView"),s=function(e,t){var t=merge(t,{visible:!0,opacity:1,scale:1,rotation:0,x:0,y:0});e.completeTween(t)},o=new i({backgroundColor:"black",visible:!1});return{zoomSpotlight:function(e,t,n){var i={duration:2e3};s(e),o.completeTween({width:e.width,height:e.height,visible:!0,z:Math.max(e.z,t.z)+1,opacity:0,spotlightX:e.width/2,spotlightY:e.height/2,spotlightRadius:0}),o.removeFromParent(),e.parent.addChild(o),e.tween({scale:2},i.duration),o.tween({opacity:1},i.duration,r.easeIn,function(){e.visible=!1,s(t),o.delayTween(500).tween({spotlightRadius:e.width},i.duration,r.easeIn,function(){o.visible=!1,o.removeFromParent(),n&&n()})})},spotlight:function(e,t,n){var i={duration:2e3};s(e),o.completeTween({width:e.width,height:e.height,visible:!0,spotlightX:e.width/2,spotlightY:e.height/2,spotlightRadius:e.width}),o.removeFromParent(),e.parent.addChild(o),o.tween({spotlightRadius:0},i.duration,r.easeIn,function(){e.visible=!1,s(t),o.delayTween(500).tween({spotlightRadius:e.width},i.duration,r.easeIn,function(){o.visible=!1,o.removeFromParent(),n&&n()})})},crossFade:function(e,t,n){s(e),s(t,{opacity:0}),e.tween({opacity:0},500,null,function(){e.visible=!1,n&&n()}),t.tween({opacity:1},500)},fade:function(e,t,n){s(e),s(t,{opacity:0}),e.tween({opacity:0},500,null,function(){e.visible=!1,t.tween({opacity:1},500,null,function(){n&&n()})})},slideUp:function(e,t,n){s(e),s(t,{y:t.parent.height}),e.tween({y:-e.height},500,r.easeIn,function(){e.visible=!1,n&&n()}),t.tween({y:0},500,r.easeIn)},slideDown:function(e,t,n){s(e),s(t,{bottom:0}),e.tween({y:e.height},500,r.easeIn,function(){e.visible=!1,n&&n()}),t.tween({y:0},500,r.easeIn)},slideLeft:function(e,t,n){s(e),s(t,{x:t.width}),e.tween({right:0},500,r.easeIn,function(){e.visible=!1,n&&n()}),t.tween({x:0},500,r.easeIn)},slideRight:function(e,t,n){s(e),s(t,{right:0}),e.tween({x:e.width},500,r.easeIn,function(){e.visible=!1,n&&n()}),t.tween({x:0},500,r.easeIn)},rotateIn:function(e,t,n){s(t,{scale:0,rotation:Math.PI}),t.tween({scale:1,rotation:0},1e3,null,function(){e.visible=!1,n&&n()})},none:function(e,t,n){s(t,{visible:!0}),e.visible=!1,n&&n()}}}),define("djinn/SceneDirector",["require","exports","module","djinn/Emitter","djinn/Collection","djinn/Scene","djinn/utils/sceneTransitions"],function(e,t,n){var r=e("djinn/Emitter"),i=e("djinn/Collection"),s=e("djinn/Scene"),o=e("djinn/utils/sceneTransitions"),t=n.exports=r.extend({init:function(e){this._super(e),this.backgroundColor=e.backgroundColor||"black",this.view=e.view},setup:function(e){this._data=e},load:function(){this._activeSceneId=null,this.scenes=new i,this._defaultScene=new s({parent:this.view,backgroundColor:this.backgroundColor,visible:!1});var e=this._data;for(var t in e){var n=e[t],r=new n.ctor({parent:this.view,id:t});for(var o in n.events)r.on(o,this,"_onSceneEvent");this.scenes.add(r)}},ready:function(){},activateScene:function(e,t){var n=this._activeSceneId,r=this.scenes.get(this._activeSceneId)||this._defaultScene,i=this.scenes.get(e);this._activeSceneId=e,i.isSetup||(i.setup(),i.isSetup=!0),i.reset(n);var t=o[t||"fade"];this.view.backgroundColor=this.backgroundColor,r&&(r.captureInputEvents=!1,r.deactivate(this._activeSceneId)),i.captureInputEvents=!1,t(r,i,bind(this,function(){this.view.backgroundColor=null,r.cleanup(e),i.activate(n)}))},_onSceneEvent:function(e){var t=this._data[e.id].events[e.eventName];this.activateScene(t.id,t.transition)}});Object.defineProperty(t.prototype,"activeSceneId",{get:function(){return this._activeSceneId}}),Object.defineProperty(t.prototype,"activeScene",{get:function(){return this.scenes.get(this._activeSceneId)}})}),define("djinn/Game",["require","exports","module","djinn/keyboard","djinn/gamepad","djinn/Emitter","djinn/globalTimer","djinn/client","djinn/stage","djinn/View","djinn/helpers/RotateDeviceView","djinn/helpers/LoadingScreen","djinn/manifest","djinn/assets","djinn/SceneDirector"],function(e,t,n){var r=e("djinn/keyboard"),i=e("djinn/gamepad"),s=e("djinn/Emitter"),o=e("djinn/globalTimer"),u=e("djinn/client"),a=e("djinn/stage"),f=e("djinn/View"),l=e("djinn/helpers/RotateDeviceView"),c=e("djinn/helpers/LoadingScreen"),h=e("djinn/manifest"),p=e("djinn/assets"),d=e("djinn/SceneDirector"),t=n.exports=s.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.showLoadingScreen=e.showLoadingScreen,this.showRotateMessage=e.showRotateMessage,this._splashFinished=!1,this._loadingProgress=0,this.view=new f({tag:"GameRootView",acceptInputEvents:!0,width:a.width,height:a.height}),a.on("resize",this,"_onStageResize"),h.orientation!=="both"&&this.showRotateMessage&&(this._rotateDeviceView=new l({parent:this.view}),u.on("resize",this,"_onClientResize")),this._loadingScreen=new c({parent:this.view,visible:!1}),this._sceneDirector=new d({view:this.view})},run:function(){o.on("tick",this,"_update"),o.start(),this.showLoadingScreen?(a.eraseBeforeRender=!0,this._loadingScreen.show(bind(this,"_onSplashFinish"))):this._onClientResize()},stop:function(){o.stop(),o.off("tick",this)},setupScenes:function(e){this._sceneDirector.setup(e)},getSceneById:function(e){return this._sceneDirector.scenes.get(e)},getActiveSceneId:function(){return this._sceneDirector.activeSceneId},getActiveScene:function(){return this._sceneDirector.activeScene},activateScene:function(e,t){this._sceneDirector.activateScene(e,t)},preloadAssets:function(e){p.load(e,bind(this,"_onLoadComplete"),bind(this,"_onLoadProgress"))},_onLoadProgress:function(e,t,n,r,i){this._loadingProgress=i,this._loadingScreen.loadingProgress=this._loadingProgress,this._checkGameReady()},_onLoadComplete:function(){a.acceptInput=!0,this._sceneDirector.load(),this.fire("load")},_update:function(e){this._react(),this.update&&this.update(e),this.view.preTick(e),this._render(),r.endFrame(),i.endFrame()},_react:function(){var e=a.getInputEvents(),t=e.length;for(var n=0;n<t;++n)this.view.react(e[n])},_render:function(){a.renderView(this.view)},_onClientResize:function(){if(!this._rotateDeviceView||!this.showRotateMessage)return;h.orientation!==u.orientation?this._rotateDeviceView.show():this._rotateDeviceView.hide()},_onStageResize:function(){this.view.width=a.width,this.view.height=a.height,this.view.reflow()},_onSplashFinish:function(){this._splashFinished=!0,this._checkGameReady()},_checkGameReady:function(){this._splashFinished&&this._loadingProgress===1&&(this._onClientResize(),this._loadingScreen.hide(bind(this,function(){a.eraseBeforeRender=!1,this._sceneDirector.ready(),this.fire("ready")})))}});t.defaults={showLoadingScreen:!1,showRotateMessage:!0}}),define("djinn/view/utils/canvas",["require","exports","module"],function(e,t,n){t.create=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},t.drawRect=function(e,t,n,r,i,s){e.fillStyle=s,e.fillRect(t,n,r,i)},t.strokeRect=function(e,t,n,r,i,s,o){e.strokeStyle=s,e.lineWidth=o,e.strokeRect(t,n,r,i)},t.drawCircle=function(e,t,n,r,i){e.fillStyle=i,e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.closePath(),e.fill()},t.drawPolygon=function(e,t,n){e.fillStyle=n,e.beginPath(),e.moveTo(t[0],t[1]);for(var r=2,i=t.length;r<i;r+=2)e.lineTo(t[r],t[r+1]);e.closePath(),e.fill()}}),define("djinn/view/Text",["require","exports","module","../View","./utils/canvas"],function(e,t,n){var r=e("../View"),i=e("./utils/canvas"),t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);e.parent&&(!e.width||e.width<1)&&(e.width=e.parent.width);if(!e.height||e.height<1)e.height=e.fontSize;this._super(e),this._buffer=i.create(1,1),this.fontFamily=e.fontFamily,this.fontSize=e.fontSize,this.color=e.color,this.strokeColor=e.strokeColor,this.strokeWidth=e.strokeWidth,this.shadowColor=e.shadowColor,this.shadowX=e.shadowX,this.shadowY=e.shadowY,this.textAlign=e.textAlign,this.verticalAlign=e.verticalAlign,this.wordWrap=e.wordWrap,this.autoSize=e.autoSize,this.text=e.text},render:function(e){this._super(e);var t=this._buffer;if(!this._text||!t)return;var n=0,r=~~(this.height/2-t.height/2);switch(this.textAlign){case"left":n=~~(-t.width*.25);break;case"center":n=~~(this.width/2-t.width*.5);break;case"right":n=~~(this.width-t.width*.75)}e.drawImage(t,0,0,t.width,t.height,n,r,t.width,t.height)},_updateBuffer:function(){var e=this._buffer,t=e.getContext("2d"),n=sprintf("%spx %s",this.fontSize,this.fontFamily);t.font=n;var r=t.measureText(this._text),i=Math.ceil(r.width),s=Math.ceil(this.fontSize);e.width=i*2,e.height=s*2,t.font=n,t.textAlign="center",t.textBaseline="middle";var o=Math.floor(e.width/2),u=Math.floor(e.height/2);t.fillStyle=this.color,t.fillText(this._text,o,u),this.strokeColor&&this.strokeWidth>0&&(t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.strokeText(this._text,o,u))}});Object.defineProperty(t.prototype,"text",{get:function(){return this._text},set:function(e){if(this._text==e)return;this._text=e===undefined?null:String(e),this._updateBuffer()}}),t.defaults={color:"rgb(0, 0, 0)",fontFamily:"Arial",fontSize:20,shadowColor:null,shadowX:1,shadowY:1,strokeColor:null,strokeWidth:null,text:"",textAlign:"left",verticalAlign:"top",wordWrap:!0,autoSize:!1}}),define("djinn/intl",[],function(){var e=__intl||{},t={get:function(t){return e[t]?arguments.length==1?e[t]:(arguments[0]=e[t],sprintf.apply(arguments,arguments)):sprintf("[undefined intl: %s]",t)},getArray:function(t){return clone(e[t])},sort:function(e){return e.sort(function(e,n){var r=t.get(e),i=t.get(n);return r<i?-1:1}),e}};return t}),define("djinn/ui/Button",["djinn/View","djinn/TextView","djinn/utils/transitions","djinn/utils/viewEffects"],function(e,t,n,r){var i=e.extend({init:function(e){var e=merge(e,i.defaults);this._super(e),this._enabled=Boolean(e.enabled),this.textView=(new t(merge({parent:this,text:e.text},e.textConf||{},i.textDefaults))).align("center","center"),this.on("inputStart",this,"_onInputStart"),this.update()},_onInputStart:function(e){return!this._enabled||this._pressing===!0?(this.fire("buttonDisabledPress",[e]),!1):(this._pressing=!0,r.buttonPress(this,{},bind(this,function(){this.fire("buttonPress",[e]),this._pressing=!1})),!0)},update:function(){}});return Object.defineProperty(i.prototype,"text",{set:function(e){this.textView.text=e}}),Object.defineProperty(i.prototype,"textConf",{set:function(e){this.textView.set(e)}}),Object.defineProperty(i.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled=e,this.update(),this.fire("change:enabled",[e])}}),i.defaults={acceptInputEvents:!0,cancelInputEvents:!0,backgroundColor:"rgb(190, 190, 190)",width:200,height:40,enabled:!0},i.textDefaults={text:"",color:"rgb(0, 0, 0)",fontSize:30,textAlign:"center",verticalAlign:"middle"},i}),define("js/view/style",["require","exports","module","djinn/math/core"],function(e,t,n){var r=e("djinn/math/core"),i={primary:"rgba(213, 155, 61, %s)",black:"rgba(20, 12, 28, %s)",white:"rgba(222, 238, 214, %s)",grey:"rgba(78, 74, 78, %s)",silver:"rgba(133, 149, 161, %s)",gold:"rgba(216, 186, 79, %s)",red:"rgba(133, 19, 20, %s)",green:"rgba(109, 170, 44, %s)",blue:"rgba(89, 125, 206, %s)",purple:"rgba(159, 76, 208, %s)",yellow:"rgba(241, 237, 121, %s)",orange:"rgba(210, 125, 44, %s)",brown:"rgba(128, 96, 65, %s)",darkBlue:"rgba(48, 52, 109, %s)",teal:"rgba(109, 194, 202, %s)"},s=function(e,t){return t===undefined?t=1:t=r.clamp(t,0,1),i[e]?sprintf(i[e],t):null},o=function(e,t){return e>.6?s("green",t):e>.3?s("orange",t):s("red",t)},u=function(e){return sprintf(e?"white":"grey")};n.exports={getColor:s,getProgressColor:o,getTextColor:u}}),define("js/view/Button",["require","exports","module","djinn/ui/Button","./style"],function(e,t,n){var r=e("djinn/ui/Button"),i=e("./style");n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.on("change:enabled",this,"_onChangeEnabled")},_onChangeEnabled:function(e){e?(this.imageY=0,this.textView.color=i.getColor("primary")):(this.imageY=this.height,this.textView.color=i.getColor("grey"))}}),t.defaults={image:"media/images/ui/buttons.png",textConf:{color:i.getColor("primary"),fontSize:24},width:240,height:80}}),define("js/spil/spilAPI",["require","exports","module","djinn/Emitter","djinn/audio/jukebox"],function(e,t,n){var r=e("djinn/Emitter"),i=e("djinn/audio/jukebox"),s={id:"576742227280291957"},o=r.extend({init:function(e){this._super(e),this.ready=!1,this._instance=null},load:function(){GameAPI.loadAPI(bind(this,function(e){var t=this._instance=e;this._logoData=t.Branding.getLogo(),this._moreGamesData=t.Branding.getLink("more_games");var n=e.Branding.getSplashScreen();if(n.show&&n.action){var r=document.getElementById("spilgames-splash-screen");r.addEventListener("click",n.action),r.className="",window.setTimeout(function(){r.className="spilgames-splash-screen-gone"},3e3)}this.ready=!0,this.fire("ready")}),s)},onReady:function(e){this.ready?e():this.on("ready",e)},getLogoData:function(){return this._logoData},getMoreGamesData:function(){return this._moreGamesData},requestAd:function(){var e=!i.muted;this._instance.GameBreak.request(function(){e&&i.mute()},function(){e&&i.unmute()})}});n.exports=new o}),define("js/spil/SpilMoreGames",["require","exports","module","djinn/intl","../view/Button","./spilAPI"],function(e,t,n){var r=e("djinn/intl"),i=e("../view/Button"),s=e("./spilAPI"),t=n.exports=i.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.on("buttonPress",this,"_onButtonPress")},_onButtonPress:function(){var e=s.getMoreGamesData();e.action&&e.action()}});t.defaults={text:r.get("MORE_GAMES")}}),define("js/view/scenes/TitleScene",["require","exports","module","djinn/intl","djinn/Scene","djinn/View","djinn/audio/jukebox","djinn/view/Text","../Button","../style","../../spil/SpilMoreGames"],function(e,t,n){var r=e("djinn/intl"),i=e("djinn/Scene"),s=e("djinn/View"),o=e("djinn/audio/jukebox"),u=e("djinn/view/Text"),a=e("../Button"),f=e("../style"),l=e("../../spil/SpilMoreGames"),c=852,h=480,p=[{imageX:0,imageY:0},{imageX:c,imageY:0},{imageX:0,imageY:h},{imageX:c,imageY:h}],t=n.exports=i.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this._playTimer=this.createBoundTimer(1e3,"_onPlayTimer").start()},setup:function(){(new s({parent:this,image:"media/images/ui/title.png",width:430,height:200,y:20,z:100})).align("center"),this._muted=(new s({parent:this,acceptInputEvents:!0,image:"media/images/ui/icons.png",imageX:o.muted?90:0,width:90,height:90,z:100})).align("right","bottom",-40,-40).on("inputStart",this,"_toggleMuted"),this._more=(new l({parent:this,z:100})).align("center","bottom",0,-40),this._play=(new a({parent:this,text:r.get("PLAY"),bottom:this._more.y-20,z:100})).align("center"),this._play.on("buttonPress",this,"_onPlay")},reset:function(){this._backgroundIndex=0,this._applyBackground()},activate:function(e){this.musicKey="title",e==="garage"&&(this.musicKey=null),this._super(e)},deactivate:function(){},cleanup:function(){this.musicKey=null,this._super()},_applyBackground:function(){this.set(p[this._backgroundIndex])},_onPlayTimer:function(){this._play.completeTween().tween({scale:1.2},50).tween({scale:1},100)},_onPlay:function(){o.play("tick"),this.fireSceneEvent("play")},_switchBackground:function(){++this._backgroundIndex>p.length-1&&(this._backgroundIndex=0),this._applyBackground()},_toggleMuted:function(){o.play("tick"),o.muted=!o.muted;var e=this._muted;e.imageX=o.muted?e.width:0}});t.defaults={image:"media/images/titleBGs.png",width:c,height:h}}),define("djinn/utils/string",{parseNumber:function(e){return Number(e.replace(/([^0-9\.])/g,""))},formatNumber:function(e){var e=String(e),t=e.split("."),n=t[0],r=t.length>1?"."+t[1]:"",i=/(\d+)(\d{3})/;while(i.test(n))n=n.replace(i,"$1,$2");return n+r},formatOrdinalNumber:function(e){var e=String(e),t="";switch(e.slice(-1)){case"1":t="st";break;case"2":t="nd";break;case"3":t="rd";break;default:t="th"}return e+t},formatTime:function(e){var t=~~(e/1e3)%60,n=~~(e/6e4)%60;return t<10&&(t="0"+t),sprintf("%s:%s",n,t)},ucfirst:function(e){return e.charAt(0).toUpperCase()+e.slice(1)},hashCharCode:function(e){var t=0;if(e.length<1)return t;for(i=0,j=e.length;i<j;i++){var n=e.charCodeAt(i);t=(t<<5)-t+n,t|=0}return Math.abs(t)}}),define("js/sim/save",["require","exports","module","djinn/utils/DataStore","djinn/utils/string","djinn/utils/array"],function(e,t,n){var r=e("djinn/utils/DataStore"),i=e("djinn/utils/string"),s=e("djinn/utils/array"),o=["player","player2","player3"],u={player:{name:"Copperhead GT",topSpeed:100,boosts:2,health:100},player2:{name:"Boomslang GTX",topSpeed:120,boosts:3,health:80},player3:{name:"Prototype X11",topSpeed:130,boosts:4,health:80}},a={player:0,player2:15e3,player3:5e4},f=new r({key:"heat_save",defaults:{cash:0,vehicles:["player"]}});t.getAllVehicles=function(){return o},t.getVehicleTypeByIndex=function(e){return o[e]},t.hasVehicle=function(e){return s.contains(f.get("vehicles"),e)},t.getVehiclePrice=function(e){return a[e]},t.getVehicleInfo=function(e){return u[e]},t.purchaseVehicle=function(e){if(t.hasVehicle(e))return;var n=t.getVehiclePrice(e);t.spendCash(n)&&t.addVehicle(e)},t.addVehicle=function(e){if(t.hasVehicle(e))return;var n=f.get("vehicles");s.pushOnce(n,e),f.set("vehicles",n)},t.getCash=function(){return f.get("cash")},t.getDisplayCash=function(){return i.formatNumber(t.getCash())},t.hasCash=function(e){return t.getCash()>=e},t.awardCash=function(e){f.increment("cash",e)},t.spendCash=function(e){return t.hasCash(e)?(f.increment("cash",-e,0),!0):!1},t.setZoneTime=function(e,n){var r=t.getZoneTime(e);(!r||n<r)&&f.set("time:"+e,n)},t.getZoneTime=function(e){return f.get("time:"+e,null)},t.getDisplayZoneTime=function(e){var n=t.getZoneTime(e);return n===null?"--:--":i.formatTime(n)},t.setZoneRank=function(e,n){var r=t.getZoneRank(e);(!r||n<r)&&f.set("rank:"+e,n)},t.getZoneRank=function(e){return f.get("rank:"+e,null)}}),define("js/view/VehicleInfo",["require","exports","module","djinn/View","djinn/view/Text","djinn/intl","../sim/save"],function(e,t,n){var r=e("djinn/View"),i=e("djinn/view/Text"),s=e("djinn/intl"),o=e("../sim/save"),t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e);var n=e.type;this._sprite=new r({parent:this,image:"media/images/"+n+".png",width:310,height:168});var u=o.getVehicleInfo(n),a=300;this._name=new i({parent:this,x:a,text:u.name,fontSize:26,color:"white"}),this._speed=new i({parent:this,x:a,y:this._name.bottom+20,text:s.get("TOP_SPEED_N",u.topSpeed),fontSize:20,color:"white"}),this._boosts=new i({parent:this,x:a,y:this._speed.bottom+6,text:s.get("BOOST_CHARGES_N",u.boosts),fontSize:20,color:"white"}),this._dura=new i({parent:this,x:a,y:this._boosts.bottom+6,text:s.get("DURABILITY_N",u.health),fontSize:20,color:"white"})}});t.defaults={width:500,height:168}}),define("js/sim/session",["require","exports","module","djinn/utils/string"],function(e,t,n){var r=e("djinn/utils/string"),i={},s={playerType:"player",zoneKey:null,"race:cash":0,"race:rank":0};t.reset=function(e){for(var t in s){if(e&&!r.contains(t,e+":"))continue;i[t]=s[t]}},t.get=function(e){return i[e]},t.set=function(e,t){i[e]=t},t.reset()}),define("djinn/ui/Carousel",["require","exports","module","djinn/math/core","djinn/View"],function(e,t,n){var r=e("djinn/math/core"),i=e("djinn/View");n.exports=i.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.items=[],this.selectedIndex=0,this.leftArrowConf=e.leftArrow,this.leftArrowDisabledConf=e.leftArrowDisabled,this.rightArrowConf=e.rightArrow,this.rightArrowDisabledConf=e.rightArrowDisabled,this.leftArrow=(new i(merge({parent:this,acceptInputEvents:!0},e.leftArrow))).align("left","center").on("inputStart",this,"_onLeft"),this.rightArrow=(new i(merge({parent:this,acceptInputEvents:!0},e.rightArrow))).align("right","center").on("inputStart",this,"_onRight")},addItem:function(e){e.acceptInputEvents=!0,e.captureInputEvents=!0,e.on("inputStart",this,"_onSelect"),this.items.push(e),this.addChild(e),e.align("center","center")},reset:function(e){e===undefined&&(e=0),this.selectedIndex=e;var t=this.items;for(var n=0,r=t.length;n<r;++n)t[n].visible=n===e;this.refresh()},refresh:function(){var e=this.items.length,t=this.selectedIndex,n=t>0;this.leftArrow.set(n?this.leftArrowConf:this.leftArrowDisabledConf);var r=t<e-1;this.rightArrow.set(r?this.rightArrowConf:this.rightArrowDisabledConf)},selectByDirection:function(e){var t=r.clamp(this.selectedIndex+e,0,this.items.length-1);this.reset(t),this.refresh(),this.fire("scroll")},_onLeft:function(){this.selectByDirection(-1)},_onRight:function(){this.selectByDirection(1)},_onSelect:function(){this.fire("select")}}),t.defaults={acceptInputEvents:!0}}),define("js/view/Carousel",["require","exports","module","djinn/ui/Carousel"],function(e,t,n){var r=e("djinn/ui/Carousel"),i=90;n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e)}}),t.defaults={leftArrow:{image:"media/images/ui/icons.png",imageX:0,imageY:i*2,width:i,height:i},leftArrowDisabled:{image:"media/images/ui/icons.png",imageX:i,imageY:i*2,width:i,height:i},rightArrow:{image:"media/images/ui/icons.png",imageX:0,imageY:i,width:i,height:i},rightArrowDisabled:{image:"media/images/ui/icons.png",imageX:i,imageY:i,width:i,height:i},width:720,height:360}}),define("js/view/scenes/GarageScene",["require","exports","module","djinn/intl","djinn/Scene","djinn/View","djinn/audio/jukebox","djinn/view/Text","djinn/utils/string","djinn/utils/viewEffects","../Button","../VehicleInfo","../style","../../sim/save","../../sim/session","../Carousel"],function(e,t,n){var r=e("djinn/intl"),i=e("djinn/Scene"),s=e("djinn/View"),o=e("djinn/audio/jukebox"),u=e("djinn/view/Text"),a=e("djinn/utils/string"),f=e("djinn/utils/viewEffects"),l=e("../Button"),c=e("../VehicleInfo"),h=e("../style"),p=e("../../sim/save"),d=e("../../sim/session"),v=e("../Carousel"),t=n.exports=i.extend({init:function(e){var e=merge(e,t.defaults);this._super(e)},setup:function(){this._title=new u({parent:this,text:r.get("YOUR_GARAGE"),color:"white",fontSize:40,textAlign:"center",y:10}),this._back=(new s({parent:this,acceptInputEvents:!0,image:"media/images/ui/icons.png",imageY:180,width:90,height:90})).align("left","bottom",10,-10),this._back.on("inputStart",this,"_onBack"),this._cash=(new u({parent:this,color:h.getColor("white"),fontSize:32,textAlign:"right",width:320})).align("right","bottom",-10,-10),this._select=(new l({parent:this,text:r.get("DRIVE")})).align("center","bottom",0,-10),this._select.on("buttonPress",this,"_onSelect"),this._select.on("buttonDisabledPress",this,"_onDisabled");var e=new c({type:"player"}),t=new c({type:"player2"}),n=new c({type:"player3"}),i=this._carousel=(new v({parent:this})).align("center","center");i.on("scroll",this,"_onScroll"),i.on("select",this,"_onSelect"),i.addItem(e),i.addItem(t),i.addItem(n)},reset:function(){this._cash.text=r.get("CASH_N",p.getDisplayCash()),this._carousel.reset(),this._select.text=r.get("DRIVE"),this._select.enabled=!0},activate:function(e){e!=="title"&&e!=="zoneSelect"&&(this.musicKey="title"),this._super(),this.captureInputEvents=!0},deactivate:function(){this.musicKey=null,this._super()},cleanup:function(){this.musicKey=null,this._super()},_onScroll:function(){o.play("tick");var e=p.getVehicleTypeByIndex(this._carousel.selectedIndex);p.hasVehicle(e)?(this._select.text=r.get("DRIVE"),this._select.enabled=!0):(this._select.text=r.get("BUY_N",a.formatNumber(p.getVehiclePrice(e))),this._select.enabled=p.getCash()>=p.getVehiclePrice(e))},_onBack:function(){o.play("tick"),this.fireSceneEvent("back")},_onSelect:function(e){var t=p.getVehicleTypeByIndex(this._carousel.selectedIndex);p.hasVehicle(t)?(o.play("engineRev"),d.set("playerType",t),this.fireSceneEvent("select")):p.getCash()>=p.getVehiclePrice(t)&&(o.play("success"),p.purchaseVehicle(t),this._onScroll(),this._cash.text=r.get("CASH_N",p.getDisplayCash()))},_onDisabled:function(){o.play("negate"),f.shake(this._select)}});t.defaults={image:"media/images/garage.png",width:852,height:480}}),define("js/sim/zones",["require","exports","module"],function(e,t,n){t.desert={rating:0,road:{sectionCount:50,curveFrequency:.25,curveMin:1,curveMax:1,hillFrequency:.25,hillMin:5,hillMax:10},trafficDensity:.2,copCount:25,racerSpeeds:[9.5,8.5,7.5],powerups:{wrench:5,cash:10,boost:2},doodads:{cactus:150,rock:40,billboard:3,billboard2:3},colors:{fog:"#9C9644",dark:{road:"#696f77",grass:"#dad45e",rumble:"#4e4a4e",lane:"#b2c2bc"},light:{road:"#6f777f",grass:"#d9cb59",rumble:"#b2c2bc"}},backdrops:{foreground:"media/images/backdrops/dunesFG.png",background:"media/images/backdrops/mountainsBG.png",sky:"media/images/backdrops/orangeSky.png"}},t.forest={rating:1,road:{sectionCount:75,curveFrequency:.5,curveMin:1,curveMax:3,hillFrequency:.5,hillMin:10,hillMax:20},trafficDensity:.4,copCount:50,racerSpeeds:[10.5,9.5,8.5],powerups:{wrench:5,cash:15,boost:2},doodads:{tree:1500,rock:200,billboard:10,billboard2:10},colors:{fog:"#346524",dark:{road:"#696f77",grass:"#3a6c25",rumble:"#4e4a4e",lane:"#b2c2bc"},light:{road:"#69756f",grass:"#346524",rumble:"#b2c2bc"}},backdrops:{foreground:"media/images/backdrops/treesFG.png",background:"media/images/backdrops/mountainsBG.png",sky:"media/images/backdrops/blueSky.png"}},t.beach={rating:2,road:{sectionCount:100,curveFrequency:.25,curveMin:1,curveMax:1,hillFrequency:.25,hillMin:5,hillMax:10},trafficDensity:.6,copCount:75,racerSpeeds:[11.5,10.5,9.5],powerups:{wrench:3,cash:20,boost:2},doodads:{palm:1e3,billboard:75,billboard2:75},colors:{fog:"#9E9700",dark:{road:"#696f77",grass:"#dad45e",rumble:"#4e4a4e",lane:"#b2c2bc"},light:{road:"#6f757c",grass:"#dbd976",rumble:"#b2c2bc"}},backdrops:{foreground:"media/images/backdrops/dunesFG.png",background:"media/images/backdrops/mountainsBG.png",sky:"media/images/backdrops/blueSky.png"}},t.mountain={rating:3,road:{sectionCount:125,curveFrequency:.5,curveMin:2,curveMax:3,hillFrequency:.75,hillMin:10,hillMax:20},trafficDensity:.8,copCount:100,racerSpeeds:[12.5,11.5,10.5],powerups:{wrench:1,cash:25,boost:2},doodads:{rock:500,tree:250,billboard:75,billboard2:75},colors:{fog:"#442434",dark:{road:"#696f77",grass:"#7e4830",rumble:"#4e4a4e",lane:"#b2c2bc"},light:{road:"#6c6b70",grass:"#854c30",rumble:"#b2c2bc"}},backdrops:{foreground:"media/images/backdrops/mountainsFG.png",background:"media/images/backdrops/mountainsBG.png",sky:"media/images/backdrops/orangeSky.png"}},t.snow={rating:4,road:{sectionCount:150,curveFrequency:.65,curveMin:3,curveMax:3,hillFrequency:.85,hillMin:15,hillMax:20},trafficDensity:1,copCount:150,racerSpeeds:[13.5,12.5,11.5],powerups:{cash:30,boost:2},doodads:{rock:500,tree:250,billboard:50,billboard2:50},colors:{fog:"#deeed6",dark:{road:"#696f77",grass:"#c7e5d4",rumble:"#4e4a4e",lane:"#b2c2bc"},light:{road:"#69777f",grass:"#deeed6",rumble:"#b2c2bc"}},backdrops:{foreground:"media/images/backdrops/treesFG.png",background:"media/images/backdrops/snowBG.png",sky:"media/images/backdrops/blueSky.png"}}}),define("js/view/ZoneTile",["require","exports","module","djinn/View","djinn/view/Text","djinn/intl","djinn/audio/jukebox","../sim/save","../sim/zones","./style"],function(e,t,n){var r=e("djinn/View"),i=e("djinn/view/Text"),s=e("djinn/intl"),o=e("djinn/audio/jukebox"),u=e("../sim/save"),a=e("../sim/zones"),f=e("./style"),l=20,c=10,t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e);var n=this._title=(new i({parent:this,color:f.getColor("white"),fontSize:26})).align("left","top",l,c);this._time=(new i({parent:this,color:f.getColor("white"),fontSize:20})).align("left","bottom",l,-c),this._rating=(new i({parent:this,color:f.getColor("grey"),fontSize:20,textAlign:"right"})).align("right","bottom",-l,-c),this._trophy=(new r({parent:this,image:"media/images/trophies.png",width:32,height:32})).align("right","top",-l,c),this.on("inputStart",this,"_onInputStart")},setZone:function(e){this._zoneKey=e,this.refresh()},refresh:function(){var e=this._zoneKey;this._title.text=s.get("ZONE_"+e.toUpperCase()),this._time.text=s.get("BEST_N",u.getDisplayZoneTime(e)),this._rating.text=s.get("RATING_"+a[e].rating);var t=u.getZoneRank(e);t>=1&&t<=3?this._trophy.set({visible:!0,imageX:(t-1)*this._trophy.width}):this._trophy.hide()},_onInputStart:function(){o.play("tick"),this.fire("select",[this._zoneKey])}});t.defaults={acceptInputEvents:!0,cancelInputEvents:!0,image:"media/images/ui/zoneTile.png",width:350,height:100}}),define("js/view/scenes/ZoneSelectScene",["require","exports","module","djinn/intl","djinn/Scene","djinn/View","djinn/audio/jukebox","djinn/view/Text","djinn/ui/Button","../ZoneTile","../style","../../sim/save","../../sim/session","../../sim/zones"],function(e,t,n){var r=e("djinn/intl"),i=e("djinn/Scene"),s=e("djinn/View"),o=e("djinn/audio/jukebox"),u=e("djinn/view/Text"),a=e("djinn/ui/Button"),f=e("../ZoneTile"),l=e("../style"),c=e("../../sim/save"),h=e("../../sim/session"),p=e("../../sim/zones"),d=20,t=n.exports=i.extend({init:function(e){var e=merge(e,t.defaults);this._super(e)},setup:function(){this._title=new u({parent:this,text:r.get("CHOOSE_ZONE"),color:l.getColor("white"),fontSize:40,textAlign:"center",y:10}),this._back=(new s({parent:this,acceptInputEvents:!0,image:"media/images/ui/icons.png",imageY:180,width:90,height:90})).align("left","bottom",10,-10),this._back.on("inputStart",this,"_onBack");var e=this._zoneTiles=[];for(var t in p){var n=new f({parent:this});n.setZone(t),n.on("select",this,"_onZoneTileSelect"),e.push(n)}e[0].set({x:~~(this.width*.25-e[0].width/2),y:this._title.bottom+d*3}),e[1].set({x:~~(this.width*.75-e[1].width/2),y:e[0].y}),e[2].set({x:e[0].x,y:e[0].bottom+d}),e[3].set({x:e[1].x,y:e[1].bottom+d}),e[4].set({x:~~(this.width/2-e[4].width/2),y:e[3].bottom+d})},reset:function(){this._zoneTiles.forEach(function(e){e.refresh()})},activate:function(e){this.musicKey="title",e==="garage"&&(this.musicKey=null),this._super(),this.captureInputEvents=!0},deactivate:function(e){this.musicKey="title",e==="garage"&&(this.musicKey=null),this._super()},cleanup:function(e){this.musicKey="title",e==="garage"&&(this.musicKey=null),this._super()},_onBack:function(){o.play("tick"),this.fireSceneEvent("back")},_onZoneTileSelect:function(e){h.set("zoneKey",e),this.fireSceneEvent("select")}});t.defaults={image:"media/images/map.png",musicKey:"title",width:852,height:480}}),define("djinn/Scroller",["require","exports","module","./View"],function(e,t,n){var r=e("./View"),t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.xOffset=e.xOffset},render:function(e){if(!this._image||!this._image.ready)return;var t=~~(this.xOffset%this.width);t===0?e.drawImage(this._image,0,0,this.width,this.height,0,0,this.width,this.height):t>0?(e.drawImage(this._image,t,0,this.width-t,this.height,0,0,this.width-t,this.height),e.drawImage(this._image,0,0,t,this.height,this.width-t,0,t,this.height)):t<0&&(e.drawImage(this._image,this.width+t,0,-t,this.height,0,0,-t,this.height),e.drawImage(this._image,0,0,this.width+t,this.height,-t,0,this.width+t,this.height))}});t.defaults={xOffset:0}}),define("djinn/view/utils/Fire",["djinn/math/core","djinn/View","djinn/stage","djinn/globalTimer"],function(e,t,n,r){var i={},s=["red","orange","yellow","white"],o=t.extend({init:function(e){var e=merge(e,o.defaults);this._super(e),this.count=e.count,this.decayMin=e.decayMin,this.decayMax=e.decayMax,this.dyingColor=e.dyingColor,this.sizeMin=e.sizeMin,this.sizeMax=e.sizeMax,this.spectrum=e.spectrum,this.speedMin=e.speedMin,this.speedMax=e.speedMax,this._bufferKey=[this.width,this.height,this.count,this.decayMin,this.decayMax,this.sizeMin,this.sizeMax,this.speedMin,this.speedMax].concat(this.spectrum).join("-");if(!i[this._bufferKey]){var t=i[this._bufferKey]={canvas:n.createBuffer(300,300),lastUpdate:0,lastRender:0,points:[]};t.ctx=t.canvas.getContext("2d")}},renderFireToBuffer:function(t){var n=t.ctx,r=t.canvas.width,i=t.canvas.height;n.save(),n.clearRect(0,0,r,i),n.translate(r/2-this.width/2,i/2-this.height/2);var s=0,o=t.points,u=this.spectrum;for(var a=0,f=u.length;a<f;++a){var l=u[a];for(var c=0,h=o.length;c<h;++c){var p=o[c],d=a==0||p.intensity>a*.3,v=p.size*p.intensity,m=p.x,g=p.y;p.dying&&p.intensity<.4&&(a>0?d=!1:l=this.dyingColor),d&&(n.beginPath(),n.fillStyle=l,n.globalAlpha=p.intensity*(1-a*.1),n.arc(m,g,Math.max(v*(1-a*.2),0),0,e.twoPi,!1),n.fill(),n.closePath(),++s)}}n.restore()},render:function(e){var t=i[this._bufferKey];r.tickCount-t.lastRender>=o.framesPerRender&&(this.renderFireToBuffer(t),t.lastRender=r.tickCount);var n=t.canvas.width,s=t.canvas.height;e.drawImage(t.canvas,0,0,n,s,this.width/2-n/2,this.height/2-n/2,n,s)},tick:function(e){var t=i[this._bufferKey];if(!t){logger.warn("[FireView] Missing buffer for: "+this._bufferKey);return}if(t.lastUpdate===r.tickCount)return;var n=t.points;n.length<this.count&&n.push(this._makeRandomPoint());var s=e/1e3;for(var o=0,u=n.length;o<u;++o){var a=n[o];a.y-=a.speed*s,a.dying?(a.intensity-=a.decay*s,a.intensity<=0&&(n[o]=this._makeRandomPoint())):(a.intensity+=e/100,a.intensity>=1&&(a.intensity=1,a.dying=!0))}t.lastUpdate=r.tickCount},_makeRandomPoint:function(){return{decay:e.random(this.decayMin*10,this.decayMax*10)/10,dying:!1,intensity:0,size:e.random(this.sizeMin,this.sizeMax),speed:e.random(this.speedMin,this.speedMax),x:e.random(0,this.width),y:e.random(0,this.height)}}});return o.defaults={count:50,decayMin:.5,decayMax:1,dyingColor:"grey",sizeMin:10,sizeMax:15,spectrum:s,speedMin:10,speedMax:50},o.framesPerRender=3,o}),define("djinn/sim/Base",["require","exports","module","../Emitter"],function(e,t,n){var r=e("../Emitter"),t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.running=!1,this.elapsed=0,this.deltaPool=0,this.deltaStep=e.deltaStep},reset:function(){this.stop(),this.elapsed=0,this.deltaPool=0},start:function(){this.running=!0},stop:function(){this.running=!1},update:function(e){if(!this.running)return;this.deltaPool+=e;var t=this.deltaStep;while(this.deltaPool>=t)this.deltaPool-=t,this._update(t),this.elapsed+=t},_update:function(e){}});t.defaults={deltaStep:16}}),define("djinn/math/PRNG",["require","exports","module","../utils/string","../utils/array"],function(e,t,n){var r=e("../utils/string"),i=e("../utils/array"),s=2147483648,o=1103515245,u=12345;n.exports=function(e){this.state=null,e&&this.seed(e)};var a=n.exports.prototype;a.seed=function(e){e?isNaN(e)&&(e=r.hashCharCode(String(e))):e=Math.floor(Math.random()*(s-1)),this.seedValue=e,this.state=e},a.normal=function(){return this.state===null?Math.random():(this.state=(o*this.state+u)%s,this.state/s)},a.integer=function(e){return Math.round(this.normal()*e)},a.range=function(e,t){return this.integer(t-e)+e},a.radians=function(e,t){var e=e||0,t=t||Math.PI*2,n=t-e;return e+n*this.normal()},a.chance=function(e){return this.normal()<=e},a.choice=function(e,t){if(e.length===0)return null;var n=this.integer(e.length-1),r=e[n];return t&&e.splice(n,1),r},a.weightedChoice=function(e){var t=arguments.length>1;if(t||i.isArray(e))e=this.autoWeight(t?arguments:e);var n=0,r={};for(var s in e){var o=~~(n*1e3);n+=e[s],r[s]={min:o,max:~~(n*1e3)}}var u=this.integer(~~(n*1e3)-1);for(var s in r){var a=r[s];if(u>=a.min&&u<a.max)return s}return logger.warn("[PRNG.weightedChoice] No matching option found!",u,r),null},a.weightedIndex=function(e,t){var n=[];for(var r=0;r<e;++r)n.push(r);var i=this.autoWeight(n,t);return+this.weightedChoice(i)},a.autoWeight=function(e,t){var t=t||2,n={},r=0;for(var i=0,s=e.length;i<s;++i){var o=Math.pow(s-i,t);n[e[i]]=o,r+=o}var u=1/r;for(var a in n)n[a]*=u;return n}}),define("djinn/math/random",["./PRNG"],function(e){return new e}),define("js/sim/prefabs/vehicles",["require","exports","module"],function(e,t,n){t.player={role:"player",position:{x:0,z:0},size:{width:250},vehicle:{health:100,maxHealth:100,gas:!1,brake:!1,steering:0,speed:0,maxSpeed:10,acceleration:.002,handling:.001,boostTime:0,boostCharges:2},racer:{rank:0,laps:0},sprite:{image:"media/images/player.png",width:310,height:168}},t.player2={role:"player",position:{x:0,z:0},size:{width:250},vehicle:{health:80,maxHealth:80,gas:!1,brake:!1,steering:0,speed:0,maxSpeed:12,acceleration:.0024,handling:.001,boostTime:0,boostCharges:3},racer:{rank:0,laps:0},sprite:{image:"media/images/player2.png",width:310,height:168}},t.player3={role:"player",position:{x:0,z:0},size:{width:250},vehicle:{health:80,maxHealth:80,gas:!1,brake:!1,steering:0,speed:0,maxSpeed:13,acceleration:.0026,handling:.001,boostTime:0,boostCharges:4},racer:{rank:0,laps:0},sprite:{image:"media/images/player3.png",width:310,height:168}},t.racer1={position:{x:0,z:0},size:{width:250},collision:{},ai:{type:"racer"},vehicle:{health:100,maxHealth:100,gas:!1,brake:!1,steering:0,speed:0,maxSpeed:9,acceleration:.003,handling:.001},racer:{rank:0,laps:0},sprite:{image:"media/images/car1.png",width:310,height:168}},t.car2={position:{x:0,z:0},size:{width:250},collision:{},ai:{type:"civilian"},vehicle:{health:100,maxHealth:100,gas:!1,brake:!1,steering:0,speed:0,maxSpeed:5,acceleration:.001,centrifugalForce:0,handling:.002},sprite:{image:"media/images/car2.png",width:310,height:168}},t.cop={position:{x:0,z:0},size:{width:250},collision:{},ai:{type:"cop"},vehicle:{health:100,maxHealth:100,gas:!1,brake:!1,steering:0,speed:0,maxSpeed:9,acceleration:.0018,centrifugalForce:0,handling:.002},sprite:{image:"media/images/cop.png",width:310,height:188}}}),define("js/sim/prefabs/powerups",["require","exports","module"],function(e,t,n){t.wrench={position:{x:0,z:0},size:{width:120},collision:{},powerup:{type:"health",amount:20},sprite:{image:"media/images/entities/powerups.png",width:200,height:200,imageX:200}},t.cash={position:{x:0,z:0},size:{width:120},collision:{},powerup:{type:"cash",amount:100},sprite:{image:"media/images/entities/powerups.png",width:200,height:200}},t.boost={position:{x:0,z:0},size:{width:120},collision:{},powerup:{type:"boost",amount:1},sprite:{image:"media/images/entities/powerups.png",width:200,height:200,imageX:400}}}),define("js/sim/prefabs/doodads",["require","exports","module"],function(e,t,n){t.finish={position:{x:0,y:0},size:{width:80},sprite:{image:"media/images/finish.png",width:250,height:125,scale:8}},t.cactus={position:{x:0,y:0},size:{width:100},collision:{},sprite:{image:"media/images/cactus.png",width:165,height:305,scale:2}},t.tree={position:{x:0,y:0},size:{width:100},collision:{},sprite:{image:"media/images/tree.png",width:150,height:300,scale:3}},t.palm={position:{x:0,y:0},size:{width:100},collision:{},sprite:{image:"media/images/palm.png",width:200,height:300,scale:3}},t.rock={position:{x:0,y:0},size:{width:100},collision:{},sprite:{image:"media/images/rock.png",width:200,height:300,scale:1.75}},t.billboard={position:{x:0,y:0},size:{width:600},collision:{},sprite:{image:"media/images/billboard.png",width:400,height:300,scale:2}},t.billboard2={position:{x:0,y:0},size:{width:600},collision:{},sprite:{image:"media/images/billboard2.png",width:400,height:300,scale:2}}}),define("js/sim/RoadBuilder",["require","exports","module","djinn/Class","djinn/utils/transitions","djinn/math/random"],function(e,t,n){var r=e("djinn/Class"),i=e("djinn/utils/transitions"),s=e("djinn/math/random"),t=n.exports=r.extend({init:function(){this.configure()},configure:function(e){var e=merge(e,t.defaults);this.width=e.width,this.sectionCount=e.sectionCount,this.segmentLength=e.segmentLength,this.rumbleLength=e.rumbleLength,this.curveFrequency=e.curveFrequency,this.curveMin=e.curveMin,this.curveMax=e.curveMax,this.hillFrequency=e.hillFrequency,this.hillMin=e.hillMin,this.hillMax=e.hillMax},reset:function(){this.road={width:this.width,length:0,maxZ:0,finishLineZ:0,segmentLength:this.segmentLength,segments:[]}},build:function(){this.reset();var e=this.road;this._addSection(25,50,25,0,0);for(var t=0;t<this.sectionCount;++t){var n=0;s.chance(this.curveFrequency)&&(n=s.range(this.curveMin,this.curveMax),n*=s.chance(.5)?1:-1);var r=0;s.chance(this.hillFrequency)&&(r=s.range(this.hillMin,this.hillMax),r*=s.chance(.5)?1:-1),this._addSection(25,50,25,n,r)}return e.finishLineZ=e.length*e.segmentLength,this._addSection(25,50,25,0,0),e.maxZ=e.length*e.segmentLength,this.road},_getLastSegmentY:function(){var e=this.road.segments;return e.length<1?0:e[e.length-1].p2.world.y},_addSegment:function(e,t){var n=this.road,r=n.length,i=this.segmentLength;n.length=n.segments.push({index:r,p1:{world:{y:this._getLastSegmentY(),z:r*i}},p2:{world:{y:t,z:(r+1)*i}},curve:e,rumbleIndex:Math.floor(r/this.rumbleLength)%2,entities:[]})},_addSection:function(e,t,n,r,s){var o=this._getLastSegmentY(),u=s*this.segmentLength,a=u-o,f=e+t+n;for(var l=0;l<e;++l)this._addSegment(i.easeIn(l,0,r,e),i.easeBoth(l,o,a,f));for(var l=0;l<t;++l)this._addSegment(r,i.easeBoth(e+l,o,a,f));for(var l=0;l<n;++l)this._addSegment(i.easeIn(l+1,r,0,n),i.easeBoth(e+t+l,o,a,f))}});t.defaults={width:2e3,sectionCount:50,segmentLength:200,rumbleLength:3,curveFrequency:.2,curveMin:1,curveMax:1,hillFrequency:.2,hillMin:15,hillMax:20}}),define("js/sim/shared/roadway",["require","exports","module"],function(e,t,n){t.getSegmentByIndex=function(e,t){var t=t%e.length;return e.segments[t]},t.getSegmentByZ=function(e,n){var r=Math.floor(n/e.segmentLength);return t.getSegmentByIndex(e,r)},t.getPositionX=function(e,t){var n=e.width/2;return~~(n+t.position.x*n)},t.checkCollision=function(e,n,r,i){if(!r.collision)return;var i=i||1,s=i/2,o=t.getPositionX(e,n),u=n.size.width,a=t.getPositionX(e,r),f=r.size.width,l=o-u*s,c=o+u*s,h=a-f*s,p=a+f*s;return!(c<h||l>p)}}),define("js/sim/shared/position",["require","exports","module"],function(e,t,n){t.isOffRoad=function(e){var t=e.position;return t.x<-1||t.x>1}}),define("js/sim/shared/vehicle",["require","exports","module","djinn/math/core","./position"],function(e,t,n){var r=e("djinn/math/core"),i=e("./position"),s=.3,o=3,u=3.75,a=20;t.isWrecked=function(e){var t=e.vehicle;return t.health<=0},t.getSpeedNormal=function(e){var t=e.vehicle;return r.clamp(t.speed/t.maxSpeed,0,1)},t.getOffRoadMaxSpeed=function(e){var t=e.vehicle;return t.maxSpeed/4},t.update=function(e,n,r){t.updateSpeed(e,n),t.updatePosition(e,n,r)},t.updateSpeed=function(e,n){var r=e.vehicle,s=r.acceleration*n,o=r.maxSpeed;r.boostTime>0&&(s*=2,o*=1.5,r.boostTime=Math.max(r.boostTime-n,0)),r.gas&&r.speed<o&&!t.isWrecked(e)?r.speed+=s:r.speed-=s,i.isOffRoad(e)&&r.speed>t.getOffRoadMaxSpeed(e)&&(r.speed-=s*2),r.speed=Math.max(r.speed,0)},t.updatePosition=function(e,n,u){var a=e.position,f=e.vehicle,l=t.getSpeedNormal(e),c=f.handling*l*n;e.ai||(i.isOffRoad(e)?a.x+=s*c*-r.sign(a.x)*.75:a.x+=u*s*c),a.x+=f.steering*c,a.x=r.clamp(a.x,-o,o),a.z+=f.speed*n},t.stop=function(e){var t=e.vehicle;t.speed=0},t.getHealthNormal=function(e){var t=e.vehicle;return r.clamp(t.health/t.maxHealth,0,1)},t.restoreHealth=function(e,t){var n=e.vehicle;n.health=Math.min(n.health+t,n.maxHealth)},t.reduceHealth=function(e,t){var n=e.vehicle;n.health=Math.max(n.health-t,0)},t.impact=function(e,n){if(n<u)return;var i=r.clamp(n/e.vehicle.maxSpeed,0,1),s=Math.round(r.interpolate(0,a,i));t.reduceHealth(e,s)}}),define("js/sim/shared/vehicleAI",["require","exports","module","djinn/math/core","./roadway"],function(e,t,n){var r=e("djinn/math/core"),i=e("./roadway"),s=40,o=1.2;t.civilian=function(e,t){var n=t.road,r=i.getSegmentByZ(n,e.position.z);e.vehicle.gas=!0,e.vehicle.steering=0;for(var u=1;u<s;++u){var a=i.getSegmentByIndex(n,r.index+u);for(var f=0;f<a.entities.length;++f){var l=a.entities[f];if(!i.checkCollision(n,e,l,o)||l.vehicle&&l.vehicle.speed>e.vehicle.speed||l.powerup)continue;var c=0;l.position.x>=.5?c=-1:l.position.x<=-0.5?c=1:c=e.position.x>l.position.x?1:-1;var h=(s-u)/(s-1);return e.vehicle.steering=c*h,!0}}},t.racer=function(e,n){t.civilian(e,n),!n.raceTime>0&&(e.vehicle.gas=!1)},t.cop=function(e,n){var o=n.road,u=i.getSegmentByZ(o,e.position.z);e.vehicle.gas=!0,e.vehicle.steering=0;if(n.raceTime>0)for(var a=1;a<s;++a){var f=i.getSegmentByIndex(o,u.index-a);if(!f)break;for(var l=0;l<f.entities.length;++l){var c=f.entities[l];if(c.role==="player"){var h=i.getPositionX(o,e),p=i.getPositionX(o,c),d=r.sign(p-h),v=(s-a)/(s-1);return e.vehicle.steering=d*v*.15,!0}}}t.civilian(e,n)}}),define("js/sim/Race",["require","exports","module","djinn/sim/Base","djinn/math/random","djinn/math/core","djinn/utils/array","djinn/utils/string","./prefabs/vehicles","./prefabs/powerups","./prefabs/doodads","./zones","./RoadBuilder","./shared/roadway","./shared/vehicle","./shared/vehicleAI","./save","./session"],function(e,t,n){var r=e("djinn/sim/Base"),i=e("djinn/math/random"),s=e("djinn/math/core"),o=e("djinn/utils/array"),u=e("djinn/utils/string"),a=e("./prefabs/vehicles"),f=e("./prefabs/powerups"),l=e("./prefabs/doodads"),c=merge(a,f,l),h=e("./zones"),p=e("./RoadBuilder"),d=e("./shared/roadway"),v=e("./shared/vehicle"),m=e("./shared/vehicleAI"),g=e("./save"),y=e("./session"),b=["car2"],w=[1e3,500,250],E=.015,t=n.exports=r.extend({init:function(e){this._super(e),y.set("zoneKey","desert"),this._roadBuilder=new p},addEntity:function(e){var t=this.getRoadSegmentByEntity(e);t.entities.push(e),e.vehicle&&this._vehicles.push(e),e.racer&&this._racers.push(e)},reset:function(){this._super(),this.gameOver=!1,this.won=!1,this.raceRunning=!1,this.startTime=null,this.endTime=null,this.cashEarned=0,this._entityIdSeed=0,this._vehicles=[],this._racers=[],this.zoneKey=y.get("zoneKey");var e=this.zone;this._roadBuilder.configure(e.road),this.road=this._roadBuilder.build(),this._initPlayer(),this._initRacers(),this._initCops(),this._initVehicles(),this._initDoodads(),this._initPowerups(),this._updateRacerRanks()},startRace:function(){this.startTime=this.elapsed,this.raceRunning=!0},endRace:function(e){this.raceRunning=!1,this.endTime=this.elapsed,this.gameOver=!0,this.won=e;if(e){var t=this.player.racer.rank,n=t-1;w[n]&&(this.cashEarned+=w[n]),g.awardCash(this.cashEarned),g.setZoneTime(this.zoneKey,this.raceTime),g.setZoneRank(this.zoneKey,t)}this.fire("gameOver",[{won:e}])},getRoadSegmentByIndex:function(e){return d.getSegmentByIndex(this.road,e)},getRoadSegmentByEntity:function(e){return this.getRoadSegmentByZ(e.position.z)},getRoadSegmentByZ:function(e){return d.getSegmentByZ(this.road,e)},controlPlayer:function(e){if(!this.raceRunning)return;this.player.vehicle.gas=!0,this.player.vehicle.steering=s.clamp(e,-1,1)},boostPlayer:function(){if(!this.raceRunning)return;var e=this.player.vehicle;e.boostCharges>0&&(--e.boostCharges,e.boostTime=5e3,this.fire("playerBoost"))},getNearestCopDistance:function(){var e=this._vehicles,t=this.player.position;t.y=t.z;var n=Infinity;for(var r=0,i=e.length;r<i;++r){var o=e[r];if(o.type!=="cop")continue;var u=o.position;u.y=u.z;var a=s.pointDistance(t,u);a<n&&(n=a)}return n},_update:function(e){this._checkGameOver(),this._updateVehicles(e);if(this.gameOver)return;this._checkCollision(),this._updateRacerRanks()},_applyPowerup:function(e,t){switch(t.powerup.type){case"health":v.restoreHealth(e,t.powerup.amount);break;case"cash":this.cashEarned+=t.powerup.amount,this.fire("cashChange");break;case"boost":e.vehicle.boostCharges+=1,this.fire("playerBoostChange")}},_checkGameOver:function(){if(this.gameOver)return;var e=this.player;v.isWrecked(e)?this.endRace(!1):e.position.z>=this.road.finishLineZ&&(this.endRace(!0),e.ai={type:"civilian"})},_updateVehicles:function(e){var t=this.road;for(var n=0,r=this._vehicles.length;n<r;++n){var i=this._vehicles[n],s=this.getRoadSegmentByEntity(i),o=i.position;i.ai&&m[i.ai.type](i,this),v.update(i,e,s.curve),o.z>t.maxZ&&(i.racer&&++i.racer.laps,o.z=o.z%t.maxZ),o.z=o.z%t.maxZ;var u=this.getRoadSegmentByEntity(i);if(s!==u){var a=s.entities.indexOf(i);s.entities.splice(a,1),u.entities.push(i)}}},_checkCollision:function(){var e=this._racers;for(var t=0,n=e.length;t<n;++t){var r=e[t],i=this.getRoadSegmentByEntity(r),s=[];for(var u=0,a=i.entities.length;u<a;++u){var f=i.entities[u];if(f.id===r.id)continue;if(!d.checkCollision(this.road,r,f))continue;var l=r.role==="player";if(f.vehicle){if(r.vehicle.speed>f.vehicle.speed){v.impact(r,r.vehicle.speed-f.vehicle.speed),r.vehicle.speed=f.vehicle.speed*.8*(f.vehicle.speed/r.vehicle.speed),r.position.z=f.position.z,l&&this.fire("playerCollideVehicle");break}}else if(f.powerup&&l)this._applyPowerup(r,f),this.fire("playerPowerup",[f.id]),s.push(u);else if(l){var c=r.vehicle.health;v.impact(r,r.vehicle.speed),r.vehicle.speed=r.vehicle.maxSpeed/5,r.position.z=f.position.z;var h=c-r.vehicle.health;h>0&&this.fire("playerDamage",[h]);break}}o.removeIndices(i.entities,s)}},_updateRacerRanks:function(){if(this.gameOver)return;var e=this._racers;e.sort(function(e,t){return e.racer.laps===t.racer.laps?t.position.z-e.position.z:t.racer.laps-e.racer.laps});for(var t=0,n=e.length;t<n;++t)e[t].racer.rank=t+1},_initPlayer:function(){var e=y.get("playerType");this.player=this._createEntity(e,{}),this.addEntity(this.player)},_initDoodads:function(){var e=this.zone,t=[];for(var n in e.doodads)for(var r=0;r<e.doodads[n];++r)t.push(n);var s=t.length,o=this.road.length/s,u=!1,a=this.road.width/2;for(var r=0;r<s;++r){var f=r*o*this.roadSegmentLength,n=i.choice(t,!0),l=this._createEntity(n,{position:{z:f}}),c=a*1.1+l.size.width/2,h=c/a+Math.random();l.position.x=u?-h:h,this.addEntity(l),u=!u}this.addEntity(this._createEntity("finish",{position:{z:this.road.finishLineZ}}))},_initVehicles:function(){var e=this.road.length,t=Math.floor(e*this.zone.trafficDensity*E),n=Math.floor(e/t);for(var r=1;r<=t;++r){var s=0+i.normal()*.5,o=i.choice(b),u=this._createEntity(o,{position:{x:i.chance(.5)?s:-s,z:n*r*this.roadSegmentLength},vehicle:{gas:!0}});u.vehicle.speed=u.vehicle.maxSpeed,this.addEntity(u)}},_initCops:function(){var e=this.zone.copCount+1,t=Math.floor(this.road.length/e);for(var n=1;n<e;++n){var r=0+i.normal()*.5,s=this._createEntity("cop",{position:{x:i.chance(.5)?r:-r,z:n*t*this.roadSegmentLength},vehicle:{gas:!0}});this.addEntity(s)}},_initRacers:function(){var e=this.zone.racerSpeeds;for(var t=0,n=e.length;t<n;++t){var r=this._createEntity("racer1",{position:{x:-0.5+t*.5,z:5e3-t*1e3},vehicle:{maxSpeed:e[t],acceleration:e[t]/(2e3+t*500)}});this.addEntity(r)}},_initPowerups:function(){var e=this.zone,t=[];for(var n in e.powerups)for(var r=0,s=e.powerups[n];r<s;++r)t.push(n);var o=t.length+1,u=Math.floor(this.road.length/o);for(var r=1;r<o;++r){var n=i.choice(t,!0),a=0+i.normal()*.75;this.addEntity(this._createEntity(n,{position:{x:i.chance(.5)?a:-a,z:r*u*this.roadSegmentLength}}))}},_createEntity:function(e,t){var n=++this._entityIdSeed,r=merge({id:n,type:e},t,c[e]);return r}}),S=t.prototype;Object.defineProperty(S,"zone",{get:function(){return h[this.zoneKey]}}),Object.defineProperty(S,"roadSegments",{get:function(){return this.road.segments}}),Object.defineProperty(S,"roadSegmentLength",{get:function(){return this.road.segmentLength}}),Object.defineProperty(S,"raceTime",{get:function(){return this.startTime===null?0:this.endTime===null?this.elapsed-this.startTime:this.endTime-this.startTime}}),Object.defineProperty(S,"raceDisplayTime",{get:function(){return u.formatTime(this.raceTime)}}),Object.defineProperty(S,"playerProgress",{get:function(){return this.gameOver&&this.won?1:s.clamp(this.player.position.z/this.road.finishLineZ,0,1)}}),Object.defineProperty(S,"playerHealthNormal",{get:function(){return v.getHealthNormal(this.player)}}),Object.defineProperty(S,"playerDisplayCash",{get:function(){return u.formatNumber(this.cashEarned)}}),Object.defineProperty(S,"playerDisplayRank",{get:function(){return u.formatOrdinalNumber(this.player.racer.rank)}}),Object.defineProperty(S,"playerRoadSegment",{get:function(){return this.getRoadSegmentByEntity(this.player)}})}),define("djinn/Client",["djinn/Emitter","djinn/manifest"],function(e,t){var n=e.extend({init:function(e){this._super(e),this.debug=!1,this._detectEnvironment(),this._updateSize();if(this.isTouch){var t=bind(this,function(e){e.preventDefault()}),n=["touchstart","touchmove","touchend"];for(var r=0,i=n.length;r<i;++r)addEventListener(n[r],t,!1)}var s=bind(this,"_updateSize");window.addEventListener("resize",s,!1),window.addEventListener("orientationchange",s,!1),window.addEventListener("DOMContentLoaded",s,!1),window.addEventListener("load",bind(this,"_onLoad"),!1),this._initVisibilityChange(),window.addEventListener("tizenhwkey",bind(this,"_onTizenHardwareKey"),!1)},toggleFullScreen:function(){var e=window.gui;if(e){var t=e.Window.get();t.toggleFullscreen()}},open:function(e){var t=window.gui;t?t.Shell.openExternal(e):location.href=e},quit:function(){var e=window.gui;if(!e)return;e.App.quit()},vibrate:function(e){if(!navigator.vibrate)return;navigator.vibrate(e)},log:function(){if(arguments.length>1)var e=sprintf.apply(null,arguments);else var e=arguments[0];this.isXDK?AppMobi.webview.execute('console.log("'+e+'");'):console&&console.log&&console.log(e)},_detectEnvironment:function(){var e=this.userAgent=navigator.userAgent;this.pixelRatio=window.devicePixelRatio||1,this.isTouch=typeof window.ontouchstart!="undefined"||!this.isBrowser,this.isFullScreen=window.navigator.standalone===!0,this.isIPhone=/iPhone OS/.test(e),this.isIPad=/iPad/.test(e),this.isIOS=this.isIPhone||this.isIPad,this.isAndroid=/Android/.test(e),this.debug&&(this.log("[client._detectEnvironment] Debugging info:"),this.log("User Agent: %s",this.userAgent),this.log("Device: %s",this.deviceType),this.log("Pixel Ratio: %s",this.pixelRatio))},_queryWindowSize:function(){if(this.isXDK)return{width:AppMobi.canvas.width,height:AppMobi.canvas.height};var e={width:~~window.innerWidth,height:~~window.innerHeight};return e},_updateSize:function(){var e=this._queryWindowSize();if(e.width!==this.width||e.height!==this.height)this.width=e.width,this.height=e.height,this.debug&&this.log("[client._updateSize] %sx%s",this.width,this.height),window.scrollTo(0,0),this.fire("resize",[this.width,this.height,this.orientation])},_onLoad:function(){this._updateSize(),this.isAndroid&&setInterval(bind(this,"_updateSize"),500)},_initVisibilityChange:function(){var e=null;this._hiddenPropertyName=null,typeof document.hidden!="undefined"?(e="visibilitychange",this._hiddenPropertyName="hidden"):typeof document.webkitHidden!="undefined"?(e="webkitvisibilitychange",this._hiddenPropertyName="webkitHidden"):typeof document.mozHidden!="undefined"?(e="mozvisibilitychange",this._hiddenPropertyName="mozHidden"):typeof document.msHidden!="undefined"&&(e="msvisibilitychange",this._hiddenPropertyName="msHidden");if(!e)return;document.addEventListener(e,bind(this,"_onVisibilityChange"),!1)},_onVisibilityChange:function(){this.fire("visibilityChange",[this.hidden])},_onTizenHardwareKey:function(e){if(e.keyName)var t=e.keyName;else if(e.originalEvent&&e.originalEvent.keyName)var t=e.originalEvent.keyName;else var t=null;switch(t){case"back":tizen.application.getCurrentApplication().exit()}}});return Object.defineProperty(n.prototype,"orientation",{get:function(){var e=this.width>=this.height?"landscape":"portrait";return isNaN(window.orientation)&&t.orientation!=="both"?t.orientation:e}}),Object.defineProperty(n.prototype,"hidden",{get:function(){return this._hiddenPropertyName?document[this._hiddenPropertyName]:!1}}),Object.defineProperty(n.prototype,"deviceType",{get:function(){return this.isAndroid?"Android":this.isIPhone?"iPhone":this.isIPad?"iPad":"Unknown"}}),Object.defineProperty(n.prototype,"isBrowser",{get:function(){return document&&typeof document.querySelectorAll=="function"&&!this.isCocoonJS&&!this.isXDK}}),Object.defineProperty(n.prototype,"isCocoonJS",{get:function(){return navigator.isCocoonJS}}),Object.defineProperty(n.prototype,"isXDK",{get:function(){return typeof AppMobi!="undefined"}}),Object.defineProperty(n.prototype,"isTizen",{get:function(){return typeof tizen!="undefined"}}),new n}),define("djinn/Sprite",["djinn/math/core","djinn/View"],function(e,t){var n=t.extend({init:function(e){e=merge(e,{animations:{}}),this._super(e),this._animations=e.animations,this._animating=!1,this._currentAnimation=null,this._frameElapsed=0,this._frameIndex=0;for(var t in this._animations)this._animations[t]=merge(this._animations[t],{frames:[],frameRate:12,flipHorizontal:!1,flipVertical:!1,loop:!0})},tick:function(e){if(!this._animating||!this._currentAnimation)return;var t=this._animations[this._currentAnimation];this._frameElapsed+=e;if(this._frameElapsed>=1e3/t.frameRate){this._frameElapsed=0,++this._frameIndex;var n=t.frames.length-1;this._frameIndex>n&&(t.loop==0?(this._frameIndex=n,this._animating=!1,this.fire("animationEnd")):this._frameIndex=0),this._showFrame()}},playAnimation:function(e,t){if(this._currentAnimation!=e||t!==!1)this._animating=!0,this._currentAnimation=e,this._frameIndex=0,this._frameElapsed=0,this._showFrame();return this._animating=!0,this},resumeAnimation:function(e){this._animating=!0,this._currentAnimation=e,this._showFrame()},stopAnimation:function(){return this._animating=!1,this},_showFrame:function(){var e=this._animations[this._currentAnimation];if(e===undefined){logger.warn("Animation not defined: ",this._currentAnimation);return}var t=e.frames[this._frameIndex];this.imageX=t[0],this.imageY=t[1]}});return Object.defineProperty(n.prototype,"currentAnimation",{get:function(){return this._currentAnimation}}),Object.defineProperty(n.prototype,"frame",{get:function(){return this._frameIndex},set:function(t){this._frameIndex=e.clamp(t,0,this.frameCount-1)}}),Object.defineProperty(n.prototype,"frameCount",{get:function(){var e=this._animations[this._currentAnimation];return e&&e.frames&&e.frames.length||0}}),n}),define("js/view/animations",{cop:{lights:{frames:[[0,0],[266,0]],loop:!0}}}),define("js/view/RaceRenderer",["require","exports","module","djinn/Client","djinn/View","djinn/Sprite","djinn/view/Text","djinn/math/core","djinn/math/random","djinn/view/utils/canvas","djinn/utils/string","./animations","./style"],function(e,t,n){var r=e("djinn/Client"),i=e("djinn/View"),s=e("djinn/Sprite"),o=e("djinn/view/Text"),u=e("djinn/math/core"),a=e("djinn/math/random"),f=e("djinn/view/utils/canvas"),l=e("djinn/utils/string"),c=e("./animations"),h=e("./style"),p=.00125;n.exports=i.extend({init:function(e){var e=merge(e);this._super(e),this.race=null,this.enableFog=!r.isTouch,this.fogDensity=5,this.lanes=3,this.resize(this.width,this.height),this._initCamera(),this._entities={}},attach:function(e){this.race=e,e.on("gameOver",this,"_onRaceGameOver")},detach:function(){this.camera.followEntity=null,this.race.removeListenersByContext(this),this.race=null},getEntity:function(e){return this._entities[e]},reset:function(){this.camera.followEntity=this.race.player;for(var e in this._entities){var t=this._entities[e];delete this._entities[e],t.destroy()}},resize:function(e,t){this.width=e,this.height=t;var n=r.isTouch?.25:.5;this.drawDistance=Math.floor(t*n),this.fogDensity=Math.floor(this.drawDistance*.016)},render:function(e){var t=this.race;if(!t)return;var n=t.road,r=t.zone.colors,i=this.camera,a=this.width,c=this.height,d=t.roadSegmentLength;if(i.followEntity){i.z=(n.maxZ+(i.followEntity.position.z-i.followDistance))%n.maxZ;var v=i.followEntity.position.z%d/d,m=t.getRoadSegmentByEntity(i.followEntity);i.x=i.followEntity.position.x,i.y=i.height+u.interpolate(m.p1.world.y,m.p2.world.y,v)}var g=t.getRoadSegmentByZ(i.z),y=i.z%d/d,b=c,w=-(g.curve*y),E=0,S=this.drawDistance,x={},T={},N={},C={};for(var k=0;k<S;++k){var L=t.getRoadSegmentByIndex(g.index+k),A=L.index<g.index?n.maxZ:0;this._project(L.p1.world,E,A,x,N,n.width),this._project(L.p2.world,E+w,A,T,C,n.width),E+=w,w+=L.curve;for(var O=0;O<L.entities.length;++O){var M=L.entities[O];if(!M.sprite.image)continue;var _=M.position.z%d/d;if(k===0&&_<=y)continue;var D=u.interpolate(N.scale,C.scale,_),P=u.interpolate(N.x,C.x,_),H=u.interpolate(N.y,C.y,_),B=this._entities[M.id];B||(B=this._entities[M.id]=new s({parent:this,image:M.sprite.image,width:M.sprite.width,height:M.sprite.height,x:0,y:0,imageX:M.sprite.imageX}),B.anchorX=0,B.anchorY=0,M.racer&&M.type!=="player"&&(B.rank=new o({parent:B,textAlign:"center",fontSize:30,color:h.getColor("white"),y:-40}))),M.role==="player"?M.vehicle.steering===0?B.imageX=0:M.vehicle.steering>0?B.imageX=B.width:M.vehicle.steering<0&&(B.imageX=B.width*2):M.racer&&(B.rank.text=l.formatOrdinalNumber(M.racer.rank)),B.updated=t.elapsed,B.z=-M.position.z;var j=D*a/2*n.width*p;B.scale=j*(M.sprite.scale||1),B.x=P-B.scaleWidth/2+n.width*a/2*M.position.x*D,B.y=H-B.scaleHeight,B.visible=B.y<b,B.visible&&H>b?B.clipY=Math.ceil((b-B.y)/B.scaleHeight*B.height):B.clipY=null}if(x.z<=i.depth||C.y>=N.y||C.y>=b)continue;var F=N.x,I=N.y,q=N.w,R=C.x,U=C.y,z=C.w,W=this._getRumbleWidth(q),X=this._getRumbleWidth(z),V=L.rumbleIndex===0?r.dark:r.light;f.drawRect(e,0,U,a,I-U,V.grass),f.drawPolygon(e,[F-q-W,I,F-q,I,R-z,U,R-z-X,U],V.rumble),f.drawPolygon(e,[F+q+W,I,F+q,I,R+z,U,R+z+X,U],V.rumble),f.drawPolygon(e,[F-q,I,F+q,I,R+z,U,R-z,U],V.road);if(V.lane){var $=this.lanes,J=this._getLaneMarkerWidth(q),K=this._getLaneMarkerWidth(z),Q=q*2/$,G=z*2/$,Y=F-q+Q,Z=R-z+G;for(var O=1;O<$;++O)f.drawPolygon(e,[Y-J/2,I,Y+J/2,I,Z+K/2,U,Z-K/2,U],V.lane),Y+=Q,Z+=G}if(this.enableFog){var et=this._calculateFog(k/S);et<1&&(e.globalAlpha=1-et,f.drawRect(e,0,I,a,U-I,r.fog),e.globalAlpha=1)}b=U}this._cullSprites()},_cullSprites:function(){var e=this.race.elapsed;for(var t in this._entities){var n=this._entities[t];n.updated!==e&&(delete this._entities[t],n.destroy())}},_initCamera:function(){var e=this.camera={x:0,y:0,z:0,height:1e3,fov:1.75,followDistance:900,followEntity:null};e.depth=1/Math.tan(e.fov/2)},_project:function(e,t,n,r,i,s){var o=this.camera,u=this.width/2,a=this.height/2;r.x=(e.x||0)-o.x*s-t,r.y=(e.y||0)-o.y,r.z=(e.z||0)-(o.z-n);var f=i.scale=o.depth/r.z;i.x=Math.round(u+f*(r.x-t)*u),i.y=Math.round(a-f*r.y*a),i.w=Math.round(f*s*u)},_calculateFog:function(e){return 1/Math.pow(Math.E,e*e*this.fogDensity)},_getRumbleWidth:function(e){return e/Math.max(6,2*this.lanes)},_getLaneMarkerWidth:function(e){return e/Math.max(32,8*this.lanes)},_onRaceGameOver:function(e){e.won&&(this.camera.followEntity=null)}})}),define("js/view/PlayerProgress",["require","exports","module","djinn/View","./style"],function(e,t,n){var r=e("djinn/View"),i=e("./style"),s="media/images/ui/playerProgress.png";n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this._indicator=(new r({parent:this,image:s,imageY:300,width:25,height:25})).align("center")},setProgress:function(e){var t=this._indicator,n=this.height-t.height-12;t.y=12+n-e*n}}),t.defaults={image:s,width:50,height:300}}),define("js/view/Options",["require","exports","module","djinn/intl","djinn/View","djinn/audio/jukebox","./style","./Button","../spil/SpilMoreGames"],function(e,t,n){var r=e("djinn/intl"),i=e("djinn/View"),s=e("djinn/audio/jukebox"),o=e("./style"),u=e("./Button"),a=e("../spil/SpilMoreGames");n.exports=i.extend({init:function(e){var e=merge(e,t.defaults);this._super(e);var n=(new i({parent:this,acceptInputEvents:!0,image:"media/images/ui/optionsBG.png",width:480,height:400})).align("center","center"),o=10,f=(new u({parent:n,text:r.get("RESUME"),y:25})).align("center").on("inputPress",this,function(){s.play("tick"),this.fire("resume")}),l=this._muted=(new u({parent:n,y:f.bottom+o})).align("center").on("inputPress",this,function(){s.play("tick"),s.muted=!s.muted,this._refresh()}),c=(new u({parent:n,text:r.get("QUIT"),y:l.bottom+o})).align("center").on("inputPress",this,function(){s.play("tick"),this.fire("quit")}),h=(new a({parent:n,y:c.bottom+o})).align("center");this._refresh()},show:function(){this._super(),this._refresh()},_refresh:function(){this._muted.text=r.get(s.muted?"SOUND_OFF":"SOUND_ON")}}),t.defaults={acceptInputEvents:!0,cancelInputEvents:!0,captureInputEvents:!0}}),define("js/view/ProgressBar",["require","exports","module","djinn/View","./style"],function(e,t,n){var r=e("djinn/View"),i=e("./style"),s="media/images/ui/progressBar.png",t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this._indicator=new r({parent:this,image:s,imageY:50}),new r({parent:this,image:s})}});Object.defineProperty(t.prototype,"progress",{set:function(e){this._indicator.x=-this.width*(1-e)}}),t.defaults={image:s,imageY:100,width:200,height:50}}),define("js/view/scenes/RaceScene",["require","exports","module","djinn/Scene","djinn/View","djinn/Scroller","djinn/view/Text","djinn/view/utils/Fire","djinn/math/core","djinn/utils/transitions","djinn/utils/string","djinn/intl","djinn/keyboard","djinn/audio/jukebox","djinn/utils/viewEffects","../../sim/Race","../../sim/session","../../sim/save","../Button","../RaceRenderer","../PlayerProgress","../Options","../ProgressBar","../style","../../spil/spilAPI","../../spil/SpilMoreGames"],function(e,t,n){var r=e("djinn/Scene"),i=e("djinn/View"),s=e("djinn/Scroller"),o=e("djinn/view/Text"),u=e("djinn/view/utils/Fire"),a=e("djinn/math/core"),f=e("djinn/utils/transitions"),l=e("djinn/utils/string"),c=e("djinn/intl"),h=e("djinn/keyboard"),p=h.keys,d=e("djinn/audio/jukebox"),v=e("djinn/utils/viewEffects"),m=e("../../sim/Race"),g=e("../../sim/session"),y=e("../../sim/save"),b=e("../Button"),w=e("../RaceRenderer"),E=e("../PlayerProgress"),S=e("../Options"),x=e("../ProgressBar"),T=e("../style"),N=e("../../spil/spilAPI"),C=e("../../spil/SpilMoreGames"),k=8e-4,L=["3","2","1","LOSE THE HEAT!"],t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),this.on("inputStart",this,"_onInputStart"),this.on("inputEnd",this,"_onInputEnd"),this._tapSign=0;var n=this._race=new m;n.on("cashChange",this,"_onRaceCashChange"),n.on("gameOver",this,"_onRaceGameOver"),n.on("playerDamage",this,"_onPlayerDamage"),n.on("playerPowerup",this,"_onPlayerPowerup"),n.on("playerCollideVehicle",this,"_onPlayerCollideVehicle"),n.on("playerBoost",this,"_onPlayerBoost"),n.on("playerBoostChange",this,"_onPlayerBoostChange"),this._sirenTimer=this.createBoundTimer(100,"_onSirenTimer"),this._tailTimer=this.createBoundTimer(100,"_onTailTimer")},setup:function(){this._sky=new s({parent:this}),this._background=new s({parent:this}),this._foreground=new s({parent:this});var e=this._raceRenderer=new w({parent:this});e.attach(this._race),this._timer=(new o({parent:this,text:"0:00",fontSize:30,color:T.getColor("white"),textAlign:"center"})).align("center","top",0,10),this._cash=(new o({parent:this,fontSize:30,textAlign:"right",color:T.getColor("white")})).align("right","bottom",-20,-20),this._pauseButton=(new i({parent:this,acceptInputEvents:!0,cancelInputEvents:!0,image:"media/images/ui/icons.png",imageY:270,width:90,height:90})).align("right","top",-20,20).on("inputStart",this,"_pause"),this._boostButton=(new i({parent:this,acceptInputEvents:!0,cancelInputEvents:!0,image:"media/images/ui/icons.png",imageY:360,width:90,height:90})).align("right","bottom",-20,-120).on("inputStart",this,"_boost"),this._boostCount=(new o({parent:this._boostButton,textAlign:"right",fontSize:32,text:"0"})).align("left","bottom",-20,-20),this._health=(new x({parent:this})).align("left","bottom",0,-20),this._playerProgress=(new E({parent:this})).align("left","center",20),this._rank=(new o({parent:this,textAlign:"right",color:T.getColor("white"),fontSize:50,bottom:this._cash.y-10})).align("right",null,-20),this._countdown=(new o({parent:this,textAlign:"center",verticalAlign:"middle",visible:!1,fontSize:100,color:"yellow",strokeColor:"orange",strokeWidth:4})).align("center","top",0,80),this._gameOverTitle=new o({parent:this,fontSize:80,strokeWidth:3,visible:!1,textAlign:"center"}),this._moreWon=(new C({parent:this,visible:!1})).align("center","bottom",0,-20),this._continueButton=(new b({parent:this,text:c.get("CONTINUE"),visible:!1})).align("center","bottom",0,-120),this._continueButton.on("buttonPress",this,"_onChoiceAPress"),this._rankText=new o({parent:this,color:T.getColor("white"),fontSize:42,strokeColor:T.getColor("black"),strokeWidth:2,textAlign:"center",y:120,visible:!1}),this._timeText=new o({parent:this,color:T.getColor("white"),fontSize:42,strokeColor:T.getColor("black"),strokeWidth:2,textAlign:"center",y:170,visible:!1}),this._cashText=new o({parent:this,color:T.getColor("white"),fontSize:42,strokeColor:T.getColor("black"),strokeWidth:2,textAlign:"center",y:220,visible:!1}),this._choiceA=(new b({parent:this,visible:!1})).align("center","center",0,-40),this._choiceA.on("buttonPress",this,"_onChoiceAPress"),this._choiceB=(new b({parent:this,text:c.get("QUIT"),visible:!1,y:this._choiceA.bottom+20})).align("center"),this._choiceB.on("buttonPress",this,"_onChoiceBPress"),this._moreLost=(new C({parent:this,y:this._choiceB.bottom+20})).align("center");var t=this._options=new S({parent:this,visible:!1});t.on("resume",this,"_resume"),t.on("quit",this,"_onChoiceBPress"),this._overlay=new i({parent:this,backgroundColor:T.getColor("black"),visible:!1}),this._damageOverlay=new i({parent:this,backgroundColor:T.getColor("red"),visible:!1})},reset:function(){d.setVolume("siren",0),this._race.reset(),this._raceRenderer.reset(),this._options.hide(),this._damageOverlay.completeTween().hide(),this._pauseButton.captureInputEvents=!0,this._timer.cancelTween({opacity:1}),this._gameOverTitle.cancelTween({visible:!1}),this._countdown.cancelTween({visible:!1}),this._moreWon.cancelTween({visible:!1}),this._continueButton.cancelTween({visible:!1}),this._rankText.cancelTween({visible:!1}),this._timeText.cancelTween({visible:!1}),this._cashText.cancelTween({visible:!1}),this._choiceA.cancelTween({visible:!1}),this._choiceB.cancelTween({visible:!1}),this._moreLost.cancelTween({visible:!1}),this._boostButton.cancelTween({visible:!0,opacity:1}),this._pauseButton.cancelTween({visible:!0,opacity:1}),this._onRaceCashChange(),this._updateBoostCount();var e=this._race.zone.backdrops;this._foreground.image=e.foreground,this._background.image=e.background,this._sky.image=e.sky},activate:function(){this._super(),this.captureInputEvents=!1,this._race.start(),this._startCountdown(),this._sirenTimer.start(),d.play("engineIdle")},deactivate:function(){d.stop("engineDriving"),d.stop("siren"),this._sirenTimer.stop()},tick:function(e){var t=this._race;this._updateInput(e),t.update(e),this._timer.text=l.formatTime(t.raceTime),this._health.progress=t.playerHealthNormal,this._playerProgress.setProgress(t.playerProgress),this._rank.text=t.playerDisplayRank;if(t.running&&!t.gameOver){var n=t.playerRoadSegment;this._foreground.xOffset-=.1*n.curve*e,this._background.xOffset-=.05*n.curve*e,this._sky.xOffset-=.025*n.curve*e}},_onInputStart:function(e){this._tapSign=a.sign(e.point.x-this.width/2)},_onInputEnd:function(e){this._tapSign=0},_onSirenTimer:function(){d.setVolume("skid",.5);var e=3e4,t=e-a.clamp(this._race.getNearestCopDistance(),0,e),n=t/e,r=a.scaleRange(5,30,n)/100;d.setVolume("siren",r)},_updateInput:function(e){if(!this.captureInputEvents)return;var t=0,n=k*e;if(this._tapSign>0||h.isDown(p.right))t=1;else if(this._tapSign<0||h.isDown(p.left))t=-1;t=a.clamp(t,-1,1),this._race.controlPlayer(t),t===0?(d.stop("skid"),this._skidded=!1):(this._skidded||d.play("skid"),this._skidded=!0),h.isDown(p.escape,!0)&&(this._race.running?this._pause():this._resume());if(h.isDown(p.space,!0)){var r=this._race.player.vehicle.boostCharges;r>0&&this._boost()}},_startCountdown:function(){var e=this._countdown;e.completeTween({visible:!1}).delayTween(750);var t=L.length;for(var n=0,r=L.length;n<r;++n){var i=L[n];e.delayTween(0,function(){--t,t>0?d.play("countdown1"):(d.play("countdown2"),d.play("engineRev"))}).tween({opacity:1,scale:0,visible:!0,text:i},0).tween({scale:1},1e3,f.easeOut),n===r-2?e.delayTween(0,bind(this,function(){d.fadeOut("engineIdle",500),d.play("engineDriving"),d.play("siren"),this._race.startRace(),this.captureInputEvents=!0})):n===r-1&&e.delayTween(1e3).tween({opacity:0},500,f.easeOut,function(){e.visible=!1})}},_onRaceGameOver:function(e){this._pauseButton.captureInputEvents=!1,this._sirenTimer.stop();var t=1e3,n=this._gameOverTitle,r=this._boostButton;r.completeTween({opacity:1}).tween({opacity:0},t/2,null,function(){r.hide()});var i=this._pauseButton;i.completeTween({opacity:1}).tween({opacity:0},t/2,null,function(){i.hide()});if(e.won)d.play("success"),d.fadeOut("engineDriving",1e3),d.fadeOut("siren",1e3),this._timer.completeTween().tween({opacity:0},500),n.completeTween({color:T.getColor("white"),scale:0,strokeColor:T.getColor("black"),text:c.get("ESCAPED").toUpperCase(),visible:!0,y:20}).tween({scale:1},t*3,f.elasticOut),this._moreWon.completeTween({opacity:0,visible:!0}).tween({opacity:1},500),this._continueButton.completeTween({opacity:0,visible:!0}).tween({opacity:1},500),this._rankText.completeTween({opacity:0,text:c.get("RANK_N",this._race.playerDisplayRank),visible:!0}).tween({opacity:1},500),this._timeText.completeTween({opacity:0,text:c.get("TIME_N",this._race.raceDisplayTime),visible:!0}).tween({opacity:1},500),this._cashText.completeTween({opacity:0,text:c.get("CASH_N",this._race.playerDisplayCash),visible:!0}).tween({opacity:1},500);else{d.stop("engineDriving"),d.fadeOut("siren",200),d.fadeOut(this.musicKey,500),n.completeTween({color:T.getColor("orange"),strokeColor:T.getColor("red"),text:c.get("WRECKED").toUpperCase(),visible:!0,y:-(n.height*2)}).tween({y:45},t,f.bounceOut);var s=this._raceRenderer.getEntity(this._race.player.id),o=(new u({parent:s,count:100,sizeMin:15,sizeMax:25,width:s.width*.8,height:s.width*.2})).align("center","bottom");this._choiceA.completeTween({text:c.get("RETRY"),opacity:0,visible:!0}).tween({opacity:1},t,f.elasticOut),this._choiceB.completeTween({opacity:0,visible:!0},t).tween({opacity:1},t,f.elasticOut),this._moreLost.completeTween({opacity:0,visible:!0},t).tween({opacity:1},t,f.elasticOut)}},_onRaceCashChange:function(){this._cash.text=c.get("CASH_N",l.formatNumber(this._race.cashEarned))},_onChoiceAPress:function(){this._race.won?(N.requestAd(),this.fireSceneEvent("continue")):this._retry()},_onChoiceBPress:function(){this.fireSceneEvent("quit")},_onPlayerDamage:function(e){d.play("damage"),v.vibrate(this);var t=this._damageOverlay;t.completeTween({opacity:0,visible:!0}).tween({opacity:.9},50).tween({opacity:0},100,null,function(){t.visible=!1})},_onPlayerPowerup:function(e){d.play("pickup");var t=this._raceRenderer.getEntity(e);if(!t)return;var n=(new i({parent:this,imageX:t.imageX,imageY:t.imageY,scaleX:0,scaleY:0,width:t.width,height:t.height})).align("center","top",0,40);n._image=t._image,n.tween({opacity:1,scaleX:1,scaleY:1},1e3,i.transitions.elasticOut).tween({opacity:0,rotation:0,scaleX:2,scaleY:2},100,null,function(){n.destroy()})},_onPlayerCollideVehicle:function(e){d.play("damage"),v.vibrate(this)},_onPlayerBoost:function(){d.play("engineRev"),v.vibrate(this),this._tails=5,this._tailTimer.start(),this._updateBoostCount()},_onPlayerBoostChange:function(){this._updateBoostCount()},_onTailTimer:function(){var e=this._raceRenderer.getEntity(this._race.player.id),t=(new i({parent:e.parent,imageX:e.imageX,imageY:e.imageY,scale:e.scale,width:e.width,height:e.height})).centerOn(e);t._image=e._image,t.tween({opacity:0,scale:e.scale*2},250,null,function(){t.destroy()}),--this._tails<=0&&this._tailTimer.stop()},_updateBoostCount:function(){var e=this._race.player.vehicle.boostCharges,t=e>0;this._boostButton.imageX=t?0:90,this._boostCount.color=T.getColor(t?"gold":"grey"),this._boostCount.text=e},_boost:function(){this._race.boostPlayer()},_pause:function(){d.play("tick"),d.pause(this.musicKey),d.pause("engineDriving"),d.pause("siren"),this._race.stop(),this._options.show()},_resume:function(){d.play(this.musicKey),d.play("engineDriving"),d.play("siren"),this._options.hide(),this._race.start()},_retry:function(){var e=this._overlay,t=500;this.captureInputEvents=!1,e.completeTween({visible:!0,opacity:0}).tween({opacity:1},t,null,bind(this,function(){this.reset()})).delayTween(t).tween({opacity:0},t,null,bind(this,function(){this.activate()}))}});t.defaults={musicKey:"gameplay",width:852,height:480}}),define("js/view/scenes",["require","exports","module","./scenes/TitleScene","./scenes/GarageScene","./scenes/ZoneSelectScene","./scenes/RaceScene"],function(e,t,n){var r=e("./scenes/TitleScene"),i=e("./scenes/GarageScene"),s=e("./scenes/ZoneSelectScene"),o=e("./scenes/RaceScene");t.title={ctor:r,events:{play:{id:"garage",transition:"slideLeft"}}},t.garage={ctor:i,events:{back:{id:"title",transition:"slideRight"},select:{id:"zoneSelect",transition:"slideLeft"}}},t.zoneSelect={ctor:s,events:{back:{id:"garage",transition:"slideRight"},select:{id:"race"}}},t.race={ctor:o,events:{"continue":{id:"zoneSelect"},quit:{id:"garage"}}}}),define("js/sounds",{inputTriggerKey:"tick",sounds:{title:{path:"media/music/title",type:"music",loop:!0},gameplay:{path:"media/music/gameplay",type:"music",loop:!0},activate:{path:"media/sounds/activate"},countdown1:{path:"media/sounds/countdown1"},countdown2:{path:"media/sounds/countdown2"},damage:{path:"media/sounds/damage"},engineDriving:{path:"media/sounds/engineDriving",loop:!0},engineIdle:{path:"media/sounds/engineIdle",loop:!0},engineRev:{path:"media/sounds/engineRev"},negate:{path:"media/sounds/negate"},pickup:{path:"media/sounds/pickup"},register:{path:"media/sounds/register"},siren:{path:"media/sounds/siren",loop:!0},skid:{path:"media/sounds/skid"},success:{path:"media/sounds/success"},tick:{path:"media/sounds/tick"}}}),define("js/spil/SpilLogo",["require","exports","module","djinn/View","djinn/assets","./spilAPI"],function(e,t,n){var r=e("djinn/View"),i=e("djinn/assets"),s=e("./spilAPI"),t=n.exports=r.extend({init:function(e){var e=merge(e,t.defaults);this._super(e),s.onReady(bind(this,"_loadLogo")),this.on("inputStart",this,"_onInputStart")},_loadLogo:function(){var e=s.getLogoData();e.image&&i.load(e.image,bind(this,function(){var t=i.get(e.image);this.width=t.width,this.height=t.height,this.image=e.image}))},_onInputStart:function(){var e=s.getLogoData();e.action&&e.action()}});t.defaults={acceptInputEvents:!0,cancelInputEvents:!0,width:1,height:1}}),define("js/Heat",["require","exports","module","djinn/Game","djinn/assets","djinn/view/Text","djinn/audio/jukebox","./view/scenes","./sounds","./spil/spilAPI","./spil/SpilLogo"],function(e,t,n){var r=e("djinn/Game"),i=e("djinn/assets"),s=e("djinn/view/Text"),o=e("djinn/audio/jukebox"),u=e("./view/scenes"),a=e("./sounds"),f=e("./spil/spilAPI"),l=e("./spil/SpilLogo");n.exports=r.extend({init:function(e){this._super(merge(e,{showLoadingScreen:!0})),f.load(),this._logo=(new l({parent:this.view,z:9999})).align("left","top"),s.defaults.fontFamily="PaytoneOne",this.on("load",this,"_onGameLoad"),this.on("ready",this,"_onGameReady"),this.setupScenes(u),o.configure(a),this.preloadAssets(["media/images/backdrops/blueSky.png","media/images/backdrops/dunesFG.png","media/images/backdrops/mountainsBG.png","media/images/backdrops/mountainsFG.png","media/images/backdrops/orangeSky.png","media/images/backdrops/snowBG.png","media/images/backdrops/treesFG.png","media/images/entities/powerups.png","media/images/billboard.png","media/images/billboard2.png","media/images/cactus.png","media/images/car1.png","media/images/car2.png","media/images/cop.png","media/images/finish.png","media/images/garage.png","media/images/map.png","media/images/palm.png","media/images/player.png","media/images/player2.png","media/images/player3.png","media/images/rock.png","media/images/trophies.png","media/images/ui/buttons.png","media/images/ui/icons.png","media/images/ui/optionsBG.png","media/images/ui/playerProgress.png","media/images/ui/progressBar.png","media/images/ui/title.png","media/images/titleBGs.png","media/images/ui/zoneTile.png"]),i.load(["media/fonts/PaytoneOne.ttf"])},_onGameLoad:function(){},_onGameReady:function(){this.activateScene("title","fade")}})});;
require([
	"djinn/global",
	"djinn/manifest",
	"djinn/assets",
	"djinn/stage"
], function (global, manifest, assets, stage) {

	// Cache embedded assets (such as base64'd images)

	// Match the stage size to specified resolutions
	stage.matchSize(manifest.sizes);

	// Run the game!
	require(["js/Heat"], function (DjinnGame) {
		var game = new DjinnGame();
		game.run();
	});

});
</script>

	<div id="spilgames-splash-screen" class="spilgames-splash-screen-gone"></div>


</body>
</html>
